summaryCtrl.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. "use strict";
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller("summaryCtrl", [
  6. "$rootScope",
  7. "$scope",
  8. "$state",
  9. "$timeout",
  10. "$interval",
  11. "$modal",
  12. "SweetAlert",
  13. "i18nService",
  14. "uiGridConstants",
  15. "uiGridGroupingConstants",
  16. "Restangular",
  17. "api_bpm_schedule",
  18. "api_bpm_data",
  19. "api_wechatfile",
  20. "api_configure_data",
  21. "api_user_data",
  22. "moment",
  23. function (
  24. $rootScope,
  25. $scope,
  26. $state,
  27. $timeout,
  28. $interval,
  29. $modal,
  30. SweetAlert,
  31. i18nService,
  32. uiGridConstants,
  33. uiGridGroupingConstants,
  34. Restangular,
  35. api_bpm_schedule,
  36. api_bpm_data,
  37. api_wechatfile,
  38. api_configure_data,
  39. api_user_data,
  40. moment
  41. ) {
  42. $scope.langs = i18nService.getAllLangs();
  43. $scope.lang = "zh-cn";
  44. i18nService.setCurrentLang($scope.lang);
  45. var loginUser = $rootScope.user;
  46. $scope.chakan = false;
  47. $scope.shanchu = false;
  48. $scope.shenhe = false;
  49. $scope.summary_recalculate = false;
  50. for (var i = 0; i < loginUser.menu.length; i++) {
  51. if (loginUser.menu[i].link == "summary_chakan") {
  52. $scope.chakan = true;
  53. }
  54. if (loginUser.menu[i].link == "summary_shanchu") {
  55. $scope.shanchu = true;
  56. }
  57. if (loginUser.menu[i].link == "summary_shenhe") {
  58. $scope.shenhe = true;
  59. }
  60. if (loginUser.menu[i].link == "summary_recalculate") {
  61. $scope.summary_recalculate = true;
  62. }
  63. }
  64. var defaultFilterData = {
  65. idx: 0,
  66. sum: 10,
  67. repairSummary:{}
  68. };
  69. var repairSummaryParameter = {
  70. idx: 0,
  71. sum: 10,
  72. operation: "",
  73. status: "",
  74. repairSummary: {},
  75. };
  76. //本地存储
  77. sessionStorage.repairSummaryParameter = JSON.stringify(repairSummaryParameter);
  78. $scope.memoryfilterData = {
  79. idx: 0,
  80. sum: 10,
  81. };
  82. // $scope.isMask = false;
  83. $scope.gridOptions = {};
  84. $scope.gridOptions.data = "myData";
  85. $scope.gridOptions.enableColumnResizing = true;
  86. $scope.gridOptions.enableFiltering = false;
  87. $scope.gridOptions.enableGridMenu = true;
  88. $scope.gridOptions.enableRowSelection = true;
  89. $scope.gridOptions.showGridFooter = true;
  90. $scope.gridOptions.showColumnFooter = false;
  91. $scope.gridOptions.useExternalFiltering = false;
  92. $scope.gridOptions.useExternalPagination = true;
  93. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  94. $scope.gridOptions.paginationPageSize = 10;
  95. $scope.gridOptions.multiSelect = true;
  96. $scope.gridOptions.enableSelectionBatchEvent = true; //使用批量使用事件
  97. //行鼠标悬浮变色功能
  98. // $scope.gridOptions.rowTemplate = '<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ng-mouseover="grid.appScope.hoveredIndex = rowRenderIndex" ng-mouseleave="grid.appScope.hoveredIndex = null" ui-grid-one-bind-id-grid="rowRenderIndex + \'-\' + col.uid + \'-cell\'" class="ui-grid-cell" ng-class="{\'ui-grid-row-header-cell\': col.isRowHeader, \'your-hover-class\': grid.appScope.hoveredIndex === rowRenderIndex}" role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell></div>';
  99. $scope.gridOptions.rowTemplate =
  100. '<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>';
  101. $scope.gridOptions.rowIdentity = function (row) {
  102. return row.id;
  103. };
  104. $scope.gridOptions.getRowIdentity = function (row) {
  105. return row.id;
  106. };
  107. $scope.transfer = function (status) {
  108. if (status === "正常") {
  109. return "执行中";
  110. } else if (status === "停止") {
  111. return "暂停中";
  112. }
  113. };
  114. $scope.searchkeys = {};
  115. $scope.endOpen = function ($event) {
  116. $event.preventDefault();
  117. $event.stopPropagation();
  118. $scope.startOpened = false;
  119. $scope.endOpened = !$scope.endOpened;
  120. };
  121. $scope.startOpen = function ($event) {
  122. $event.preventDefault();
  123. $event.stopPropagation();
  124. $scope.endOpened = false;
  125. $scope.startOpened = !$scope.startOpened;
  126. };
  127. //受理人,处理人
  128. var getUser = function (fieldatas) {
  129. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  130. $scope.handlingPersonnelUser = data.list;
  131. });
  132. }
  133. //处理人过滤
  134. $scope.onChangehandling = function (key = "") {
  135. var filuser = {
  136. "idx": 0,
  137. "sum": 10,
  138. "user": {
  139. "name": key,
  140. 'selectType': "pinyin_qs",
  141. engineer: 1,
  142. }
  143. }
  144. getUser(filuser);
  145. }
  146. //状态
  147. $scope.state = [];
  148. $scope.getStatus = function(){
  149. $scope.state = [
  150. {id: 1, name: '暂存'},
  151. {id: 2, name: '未审核'},
  152. {id: 3, name: '审核通过'},
  153. ]
  154. }
  155. $scope.getStatus();
  156. $scope.gridOptions.columnDefs = [
  157. {
  158. name: "item",
  159. displayName: "序号",
  160. width: 50,
  161. enableFiltering: false,
  162. },
  163. {
  164. name: "incidentSign",
  165. displayName: "事件单号",
  166. width: "10%",
  167. enableFiltering: false,
  168. },
  169. {
  170. name: "description",
  171. displayName: "故障描述",
  172. width: "400",
  173. enableFiltering: false,
  174. // cellTemplate: '<div class="ui-grid-cell-contents">{{row.entity.planStartTime.length>16?grid.appScope.transferTime(row.entity.planStartTime):row.entity.planStartTime}}</div>'
  175. },
  176. {
  177. name: "maintainer",
  178. displayName: "维修人",
  179. width: "10%",
  180. enableFiltering: false,
  181. cellTemplate: '<div class="ui-grid-cell-contents">{{row.entity.maintainer ? row.entity.maintainer.name : ""}}</div>'
  182. },
  183. {
  184. name: "totalMaintenancePrice",
  185. displayName: "维修总价",
  186. width: "10%",
  187. enableFiltering: false,
  188. cellTemplate: '<div class="ui-grid-cell-contents">{{row.entity.totalMaintenancePrice || 0}}元</div>'
  189. },
  190. {
  191. name: "createTime",
  192. displayName: "生成时间",
  193. width: "11%",
  194. enableFiltering: false,
  195. cellTemplate: '<div class="ui-grid-cell-contents">{{ grid.appScope.transferTime(row.entity.createTime) }}</div>'
  196. },
  197. {
  198. name: "state",
  199. displayName: "状态",
  200. width: "6%",
  201. enableFiltering: false,
  202. cellTemplate:
  203. '<div class="ui-grid-cell-contents"><span ng-if="row.entity.state == 1">暂存</span><span ng-if="row.entity.state == 2">未审核</span><span ng-if="row.entity.state == 3">审核通过</span></div>',
  204. },
  205. {
  206. minWidth: "230",
  207. name: "操作",
  208. enableFiltering: false,
  209. cellTemplate:
  210. '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
  211. '<a ng-click="grid.appScope.seeFunction(row.entity)" ng-if="grid.appScope.chakan" class="bianjifont">查看</a>' +
  212. '<a ng-click="grid.appScope.removeData(row.entity)" ng-if="grid.appScope.shanchu" class="bianjifont">删除</a>' +
  213. '<a ng-click="grid.appScope.runFunction(row.entity)" ng-if="grid.appScope.shenhe && row.entity.state == 2" class="bianjifont">审核通过</a>' +
  214. '<a ng-click="grid.appScope.recalculate(row.entity)" ng-if="grid.appScope.summary_recalculate && (row.entity.state == 1 || row.entity.state == 2)" class="bianjifont">重算</a>' +
  215. "</div>",
  216. },
  217. // { name: 'planTime2', displayName: '截止时间', width: 160, enableFiltering: false },
  218. ];
  219. $scope.transferTime = function (time) {
  220. if(time){
  221. return moment(time).format("YYYY-MM-DD HH:mm");
  222. }else{
  223. return '';
  224. }
  225. };
  226. $scope.inspectdata = {};
  227. //跳转到查看列表
  228. $scope.seeFunction = function (data) {
  229. console.log(data)
  230. $state.go("app.incident.summaryDetail", {
  231. incidentId: data.incidentId || '',
  232. categoryId: data.incidentCategoryId || '',
  233. dutyId: data.incidentDutyId || '',
  234. id: data.id,
  235. });
  236. };
  237. //审核通过
  238. $scope.runFunction = function (data) {
  239. var modalInstance = $modal.open({
  240. // templateUrl: 'assets/views/inspect/changRun.html',
  241. templateUrl: "assets/views/delete.html",
  242. // size: "sm",
  243. controller: function ($scope, $modalInstance) {
  244. $scope.isRunFunction = true;
  245. var status = "";
  246. $scope.title = "审核通过";
  247. $scope.connect = "确定要审核通过?";
  248. $scope.ok = function () {
  249. $modalInstance.close(data);
  250. };
  251. $scope.cancel = function () {
  252. $modalInstance.dismiss("cancel");
  253. };
  254. },
  255. size: "sm",
  256. });
  257. modalInstance.result.then(function (result) {
  258. if (result) {
  259. var toData = {
  260. summaryId: result.id,
  261. };
  262. api_bpm_data.approved(toData).then(
  263. function (response) {
  264. var myData = Restangular.stripRestangular(response);
  265. if (myData.status == 200) {
  266. SweetAlert.swal({
  267. title: "操作成功!",
  268. type: "success"
  269. }, function() {
  270. $scope.refreshData("expand-right", $scope.fileData);
  271. })
  272. }else{
  273. SweetAlert.swal({
  274. title: "操作失败!",
  275. text: myData.msg || '请求数据失败!',
  276. type: "error"
  277. }, function() {
  278. $scope.refreshData("expand-right", $scope.fileData);
  279. })
  280. }
  281. },
  282. function () {
  283. // $scope.ldloading[style.replace('-', '_')] = false;
  284. }
  285. );
  286. }
  287. });
  288. };
  289. //重算
  290. $scope.recalculate = function (data) {
  291. var modalInstance = $modal.open({
  292. // templateUrl: 'assets/views/inspect/changRun.html',
  293. templateUrl: "assets/views/delete.html",
  294. // size: "sm",
  295. controller: function ($scope, $modalInstance) {
  296. $scope.isRunFunction = true;
  297. var status = "";
  298. $scope.title = "重算";
  299. $scope.connect = "确定要重算?";
  300. $scope.ok = function () {
  301. $modalInstance.close(data);
  302. };
  303. $scope.cancel = function () {
  304. $modalInstance.dismiss("cancel");
  305. };
  306. },
  307. size: "sm",
  308. });
  309. modalInstance.result.then(function (result) {
  310. if (result) {
  311. var toData = {
  312. repairSummary: { id: result.id },
  313. };
  314. api_bpm_data.updData("repairSummary", toData).then(
  315. function (response) {
  316. var myData = Restangular.stripRestangular(response);
  317. if (myData.status == 200) {
  318. SweetAlert.swal({
  319. title: "操作成功!",
  320. type: "success"
  321. }, function() {
  322. $scope.refreshData("expand-right", $scope.fileData);
  323. })
  324. }else{
  325. SweetAlert.swal({
  326. title: "操作失败!",
  327. text: myData.msg || '请求数据失败!',
  328. type: "error"
  329. }, function() {
  330. $scope.refreshData("expand-right", $scope.fileData);
  331. })
  332. }
  333. },
  334. function () {
  335. // $scope.ldloading[style.replace('-', '_')] = false;
  336. }
  337. );
  338. }
  339. });
  340. };
  341. //行删除
  342. $scope.removeData = function (item) {
  343. console.log($scope.selected.items);
  344. var rmDatas = [item] || $scope.selected.items;
  345. var modalInstance = $modal.open({
  346. templateUrl: "assets/views/delete.html",
  347. controller: function ($scope, $modalInstance) {
  348. $scope.title = "删除";
  349. $scope.connect = "确定要删除?";
  350. $scope.ok = function () {
  351. $modalInstance.close("start");
  352. };
  353. $scope.cancel = function () {
  354. $modalInstance.dismiss("cancel");
  355. };
  356. },
  357. size: "sm",
  358. });
  359. modalInstance.result.then(
  360. function (result) {
  361. if (result) {
  362. if (rmDatas.length != 0) {
  363. $rootScope.isMask = true;
  364. }
  365. var rmvList = [];
  366. angular.forEach(rmDatas, function (item) {
  367. rmvList.push(item.id);
  368. });
  369. if (rmvList.length > 0) {
  370. api_bpm_data
  371. .rmvData("repairSummary", rmvList)
  372. .then(function (response) {
  373. if (response.status == 200) {
  374. $rootScope.isMask = false;
  375. SweetAlert.swal(
  376. {
  377. title: "删除成功!",
  378. type: "success",
  379. confirmButtonColor: "#007AFF",
  380. },
  381. function () {
  382. $scope.myData = _.reject($scope.myData, function (o) {
  383. return _.includes(rmvList, o.id);
  384. });
  385. $scope.selected = {
  386. items: [],
  387. };
  388. }
  389. );
  390. $scope.gridApi.selection.clearSelectedRows();
  391. $scope.refreshData("expand-right", $scope.fileData);
  392. //取消遮罩层
  393. // $scope.isMask = false;
  394. } else {
  395. $rootScope.isMask = false;
  396. SweetAlert.swal({
  397. title: "操作异常!",
  398. text: "系统异常,请稍后重试,或者联系管理员!",
  399. type: "error",
  400. });
  401. }
  402. });
  403. }
  404. }
  405. },
  406. function () {
  407. // $scope.ldloading[style.replace('-', '_')] = false;
  408. }
  409. );
  410. };
  411. $scope.selected = {
  412. items: [],
  413. };
  414. $scope.editted = {
  415. items: [],
  416. };
  417. $scope.testRow = [];
  418. $scope.gridOptions.onRegisterApi = function (gridApi) {
  419. //导入gridApi对象
  420. $scope.gridApi = gridApi;
  421. //分页选项
  422. gridApi.pagination.on.paginationChanged(
  423. $scope,
  424. function (newPage, pageSize) {
  425. var filterData = JSON.parse(sessionStorage.repairSummaryParameter);
  426. var filtersData = {};
  427. filtersData.idx = newPage - 1;
  428. filtersData.sum = pageSize;
  429. $scope.pageNum = $scope.gridApi.pagination.getPage() - 1;
  430. // console.log(pp);
  431. filterData.idx = $scope.pageNum;
  432. $scope.fileData.idx = newPage - 1;
  433. $scope.fileData.sum = pageSize;
  434. sessionStorage.repairSummaryParameter = JSON.stringify(filterData);
  435. $scope.refreshData("expand-right", $scope.fileData);
  436. }
  437. );
  438. //勾选行事件
  439. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  440. if (data.isSelected) {
  441. $scope.selected.items.push(data.entity);
  442. } else {
  443. //objs:需要遍历的集合 data:遍历时当前的数据 index:遍历时当前索引
  444. //array:需要遍历的集合,每次遍历时都会把objs原样的传一次。
  445. //angular.forEach(objs, function(data,index,array)
  446. angular.forEach(
  447. $scope.selected.items,
  448. function (ObjIndex, index, destObj) {
  449. // console.log(ObjIndex);
  450. // console.log(index);
  451. // console.log(destObj);
  452. if (ObjIndex.id == data.entity.id) {
  453. destObj.splice(index, 1);
  454. }
  455. }
  456. );
  457. }
  458. });
  459. //批量全选
  460. gridApi.selection.on.rowSelectionChangedBatch(
  461. $scope,
  462. function (rows, event) {
  463. // if ($scope.selected.items.length != 0) {
  464. // $scope.selected.items = [];
  465. angular.forEach(rows, function (ObjIndex, index, destObj) {
  466. if (ObjIndex.isSelected) {
  467. $scope.selected.items.push(ObjIndex.entity);
  468. } else {
  469. $scope.selected.items = [];
  470. // $scope.selected.items.splice(index, 1);
  471. }
  472. });
  473. // } else {
  474. // }
  475. // $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  476. // if ($scope.selected.items.length == 0) {
  477. // $scope.selected.items = $scope.mySelectedRows;
  478. // } else if ($scope.mySelectedRows.length == 0) {
  479. // for (var i = 0; i < $scope.selected.items.length; i++) {
  480. // for (var j = 0; j < rows.length; j++) {
  481. // if ($scope.selected.items[i].id == rows[j].entity.id) {
  482. // $scope.selected.items.splice(i, 1);
  483. // }
  484. // }
  485. // }
  486. // } else {
  487. // angular.forEach($scope.mySelectedRows, function(item) {
  488. // $scope.selected.items.push(item);
  489. // });
  490. // }
  491. }
  492. );
  493. //列过滤事件
  494. gridApi.core.on.filterChanged($scope, function () {
  495. var grid = this.grid;
  496. var filterData = JSON.parse(sessionStorage.repairSummaryParameter);
  497. angular.forEach(grid.columns, function (item) {
  498. if (item.enableFiltering) {
  499. if (
  500. angular.isDefined(item.filters[0].term) &&
  501. item.filters[0].term != ""
  502. ) {
  503. if (angular.isUndefined(filterData["repairSummary"])) {
  504. filterData["repairSummary"] = {};
  505. }
  506. filterData["repairSummary"]["title"] = item.filters[0].term;
  507. }
  508. }
  509. });
  510. sessionStorage.repairSummaryParameter = JSON.stringify(filterData);
  511. $scope.refreshData("expand-right", filterData);
  512. });
  513. };
  514. // 重置
  515. $scope.clear = function () {
  516. $scope.searchkeys = {};
  517. $scope.refreshData('expand-right');
  518. }
  519. //数据刷新
  520. $scope.refreshData = function (style, filterData) {
  521. $scope.ldloading[style.replace("-", "_")] = true;
  522. if (angular.isUndefined(filterData)) {
  523. filterData = defaultFilterData;
  524. }
  525. $scope.myData = [];
  526. if($rootScope.user.duty){
  527. filterData.repairSummary.dutyId = $rootScope.user.duty.id;
  528. }else if($rootScope.user.branch){
  529. filterData.repairSummary.branch = $rootScope.user.branch.id;
  530. }
  531. console.log($scope.searchkeys)
  532. Object.assign(filterData.repairSummary, {
  533. incidentSign: $scope.searchkeys.incidentSign || undefined,
  534. startTime: $scope.searchkeys.startTime ? moment($scope.searchkeys.startTime).startOf('day').format('YYYY-MM-DD HH:mm:ss') : undefined,
  535. endTime: $scope.searchkeys.endTime ? moment($scope.searchkeys.endTime).endOf('day').format('YYYY-MM-DD HH:mm:ss') : undefined,
  536. state: $scope.searchkeys.state ? $scope.searchkeys.state.id : undefined,
  537. maintainer: $scope.searchkeys.maintainer || undefined,
  538. })
  539. api_bpm_data.fetchDataList("repairSummary", filterData).then(
  540. function (data) {
  541. var myData = Restangular.stripRestangular(data);
  542. $scope.gridOptions.totalItems = myData.totalNum;
  543. if (angular.isArray(myData.list)) {
  544. $scope.myData = myData.list;
  545. for (var i = 0; i < $scope.myData.length; i++) {
  546. $scope.myData[i]["item"] =
  547. i + 1 + filterData.idx * filterData.sum;
  548. if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
  549. $scope.myData[i].percent = (
  550. ($scope.myData[i].completed * 100) /
  551. ($scope.myData[i].doing + $scope.myData[i].completed)
  552. ).toFixed(1);
  553. } else if ($scope.myData[i].completed == 0) {
  554. $scope.myData[i].percent = "0.0";
  555. } else {
  556. $scope.myData[i].percent = "0.0";
  557. }
  558. }
  559. console.log($scope.myData);
  560. for (var i = 0; i < $scope.myData.length; i++) {
  561. if ($scope.myData[i].status == "正常") {
  562. $scope.myData[i].style = "fa fa-play";
  563. } else if ($scope.myData[i].status == "停止") {
  564. $scope.myData[i].style = "fa fa-pause";
  565. }
  566. $scope.myData[i].runStatus = $scope.transfer(
  567. $scope.myData[i].status
  568. );
  569. }
  570. } else {
  571. SweetAlert.swal({
  572. title: "数据为空",
  573. text: myData.data,
  574. type: "warning",
  575. });
  576. }
  577. $scope.ldloading[style.replace("-", "_")] = false;
  578. },
  579. function () {
  580. $scope.ldloading[style.replace("-", "_")] = false;
  581. }
  582. );
  583. };
  584. $scope.refreshData2 = function (style, filterData) {
  585. $scope.ldloading[style.replace("-", "_")] = true;
  586. if (angular.isUndefined(filterData)) {
  587. filterData = defaultFilterData;
  588. }
  589. // $scope.myData = [];
  590. if($rootScope.user.duty){
  591. filterData.repairSummary.dutyId = $rootScope.user.duty.id;
  592. }else if($rootScope.user.branch){
  593. filterData.repairSummary.branch = $rootScope.user.branch.id;
  594. }
  595. Object.assign(filterData.repairSummary, {
  596. incidentSign: $scope.searchkeys.incidentSign || undefined,
  597. startTime: $scope.searchkeys.startTime ? moment($scope.searchkeys.startTime).startOf('day').format('YYYY-MM-DD HH:mm:ss') : undefined,
  598. endTime: $scope.searchkeys.endTime ? moment($scope.searchkeys.endTime).endOf('day').format('YYYY-MM-DD HH:mm:ss') : undefined,
  599. state: $scope.searchkeys.state ? $scope.searchkeys.state.id : undefined,
  600. maintainer: $scope.searchkeys.maintainer || undefined,
  601. })
  602. api_bpm_data.fetchDataList("repairSummary", filterData).then(
  603. function (data) {
  604. var myData = Restangular.stripRestangular(data);
  605. $scope.gridOptions.totalItems = myData.totalNum;
  606. if (angular.isArray(myData.list)) {
  607. $scope.myData = myData.list;
  608. for (var i = 0; i < $scope.myData.length; i++) {
  609. $scope.myData[i]["item"] =
  610. i + 1 + filterData.idx * filterData.sum;
  611. if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
  612. $scope.myData[i].percent = (
  613. ($scope.myData[i].completed * 100) /
  614. ($scope.myData[i].doing + $scope.myData[i].completed)
  615. ).toFixed(1);
  616. } else if ($scope.myData[i].completed == 0) {
  617. $scope.myData[i].percent = "0.0";
  618. } else {
  619. $scope.myData[i].percent = "0.0";
  620. }
  621. }
  622. console.log($scope.myData);
  623. for (var i = 0; i < $scope.myData.length; i++) {
  624. if ($scope.myData[i].status == "正常") {
  625. $scope.myData[i].style = "fa fa-play";
  626. } else if ($scope.myData[i].status == "停止") {
  627. $scope.myData[i].style = "fa fa-pause";
  628. }
  629. $scope.myData[i].runStatus = $scope.transfer(
  630. $scope.myData[i].status
  631. );
  632. }
  633. } else {
  634. SweetAlert.swal({
  635. title: "数据为空",
  636. text: myData.data,
  637. type: "warning",
  638. });
  639. }
  640. $scope.ldloading[style.replace("-", "_")] = false;
  641. },
  642. function () {
  643. $scope.ldloading[style.replace("-", "_")] = false;
  644. }
  645. );
  646. };
  647. $scope.ldloading = {};
  648. $scope.fileData = {
  649. idx: 0,
  650. sum: 10,
  651. repairSummary: {},
  652. };
  653. $scope.inspecttype = {};
  654. $scope.searchinspe = function (item) {
  655. $scope.refreshData("expand-right", $scope.fileData);
  656. };
  657. $scope.refresh = function () {
  658. var jry_filterData = JSON.parse(sessionStorage.repairSummaryParameter);
  659. var intervalData = {};
  660. intervalData.idx = jry_filterData.idx;
  661. intervalData.sum = jry_filterData.sum;
  662. intervalData.repairSummary = $scope.inspectdata;
  663. $scope.refreshData("expand-right", intervalData);
  664. };
  665. $scope.refreshData("expand-right", $scope.fileData);
  666. $scope.timer = $interval(function () {
  667. $scope.refreshData2("expand-right", $scope.fileData);
  668. }, $rootScope.refreshTime);
  669. $scope.$on("$destroy", function () {
  670. $interval.cancel($scope.timer);
  671. });
  672. },
  673. ]);