integralCtrl.js 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. "use strict";
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller("integralCtrl", [
  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_simple",
  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_simple,
  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.xinzeng = false;
  47. $scope.shanchu = false;
  48. $scope.bianji = false;
  49. $scope.zantingzhixing = false;
  50. for (var i = 0; i < loginUser.menu.length; i++) {
  51. if (loginUser.menu[i].link == "xunjianjihua_xinzeng") {
  52. $scope.xinzeng = true;
  53. }
  54. if (loginUser.menu[i].link == "xunjianjihua_shanchu") {
  55. $scope.shanchu = true;
  56. }
  57. if (loginUser.menu[i].link == "xunjianjihua_bianji") {
  58. $scope.bianji = true;
  59. }
  60. if (loginUser.menu[i].link == "xunjianjihua_zantingzhixing") {
  61. $scope.zantingzhixing = true;
  62. }
  63. }
  64. $scope.isIncidentManager = false;
  65. loginUser.role.forEach(v=>{
  66. if(v.rolecode === 'incident manager'){
  67. $scope.isIncidentManager = true;
  68. }
  69. })
  70. var defaultFilterData = {
  71. idx: 0,
  72. sum: 10,
  73. };
  74. var inspectPlanParameter = {
  75. idx: 0,
  76. sum: 10,
  77. operation: "",
  78. status: "",
  79. inspection: {
  80. inspectionTypeDTO: {
  81. id: "",
  82. },
  83. },
  84. };
  85. //本地存储
  86. sessionStorage.inspectPlanParameter = JSON.stringify(inspectPlanParameter);
  87. $scope.memoryfilterData = {
  88. idx: 0,
  89. sum: 10,
  90. };
  91. // $scope.isMask = false;
  92. $scope.gridOptions = {};
  93. $scope.gridOptions.data = "myData";
  94. $scope.gridOptions.enableColumnResizing = true;
  95. $scope.gridOptions.enableFiltering = false;
  96. $scope.gridOptions.enableGridMenu = true;
  97. $scope.gridOptions.enableRowSelection = true;
  98. $scope.gridOptions.showGridFooter = true;
  99. $scope.gridOptions.showColumnFooter = false;
  100. $scope.gridOptions.useExternalFiltering = false;
  101. $scope.gridOptions.useExternalPagination = true;
  102. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  103. $scope.gridOptions.paginationPageSize = 10;
  104. $scope.gridOptions.multiSelect = true;
  105. // $scope.gridOptions.enableSelectionBatchEvent = true; //使用批量使用事件
  106. //行鼠标悬浮变色功能
  107. // $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>';
  108. // $scope.gridOptions.rowTemplate =
  109. // '<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>';
  110. $scope.gridOptions.rowIdentity = function (row) {
  111. return row.id;
  112. };
  113. $scope.gridOptions.getRowIdentity = function (row) {
  114. return row.id;
  115. };
  116. //待审核的才能批量审核
  117. $scope.gridOptions.isRowSelectable = function (row,i) {
  118. console.log(row);
  119. if (row.entity.auditState.value == 0) {
  120. return true;
  121. } else {
  122. return false;
  123. }
  124. };
  125. $scope.transfer = function (status) {
  126. if (status === "正常") {
  127. return "执行中";
  128. } else if (status === "停止") {
  129. return "暂停中";
  130. }
  131. };
  132. $scope.gridOptions.columnDefs = [
  133. {
  134. name: "item",
  135. displayName: "序号",
  136. width: 50,
  137. enableFiltering: false,
  138. },
  139. {
  140. name: "description",
  141. displayName: "故障描述",
  142. width: "10%",
  143. enableFiltering: true,
  144. cellTemplate:
  145. '<div class="ui-grid-cell-contents">{{row.entity.incident?row.entity.incident.description:""}}</div>',
  146. },
  147. {
  148. name: "category",
  149. displayName: "故障现象",
  150. width: "10%",
  151. enableFiltering: false,
  152. cellTemplate:
  153. '<div class="ui-grid-cell-contents">{{row.entity.incident?row.entity.incident.category.category:""}}</div>',
  154. },
  155. {
  156. name: "handlerUserName",
  157. displayName: "处理人",
  158. width: "140",
  159. enableFiltering: false,
  160. },
  161. {
  162. name: "planEndTime",
  163. displayName: "登记时间",
  164. width: "200",
  165. enableFiltering: false,
  166. cellTemplate:
  167. '<div class="ui-grid-cell-contents">{{row.entity.addTime | date:"yyyy-MM-dd HH:mm:ss"}}</div>',
  168. },
  169. {
  170. name: "sourceScore",
  171. displayName: "原工时",
  172. width: "109",
  173. enableFiltering: false,
  174. },
  175. {
  176. name: "currentScore",
  177. displayName: "最终工时",
  178. width: "11%",
  179. enableFiltering: false,
  180. },
  181. {
  182. name: "updateReason",
  183. displayName: "升级原因",
  184. width: "12%",
  185. enableFiltering: false,
  186. },
  187. {
  188. name: "auditState.desc",
  189. displayName: "审核状态",
  190. width: "15%",
  191. enableFiltering: false,
  192. },
  193. {
  194. minWidth: "230",
  195. name: "操作",
  196. enableFiltering: false,
  197. cellTemplate:
  198. '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
  199. // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="编辑" tooltip-placement="right"><i class="icon iconfont icon-bianji bianjifont"></i></a>' +
  200. '<a ng-click="grid.appScope.toDetail(row.entity.incident)" class="bianjifont">查看事件</a>' +
  201. '<a ng-click="grid.appScope.toAudit(row.entity)" class="bianjifont" ng-if="grid.appScope.isIncidentManager&&row.entity.auditState.value == 0">审核</a>' +
  202. // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" ng-show="{{(row.entity.status.name==\'正常\'||row.entity.status.name==\'停止\')&&grid.appScope.bianji}}" class="bianjifont">编辑</a>' +
  203. // '<a ng-click="grid.appScope.runFunction(row.entity)" tooltip={{row.entity.runStatus}} tooltip-placement="left"><i class={{row.entity.style}}/></a>' +
  204. // '<a ng-click="grid.appScope.runFunction(row.entity)" ng-show="{{row.entity.status.name==\'正常\'&&grid.appScope.zantingzhixing}}" class="bianjifont">执行中</a>' +
  205. // '<a ng-click="grid.appScope.runFunction(row.entity)" ng-show="{{row.entity.status.name==\'停止\'&&grid.appScope.zantingzhixing}}" class="bianjifont">暂停中</a>' +
  206. "</div>",
  207. },
  208. // { name: 'planTime2', displayName: '截止时间', width: 160, enableFiltering: false },
  209. ];
  210. $scope.transferTime = function (time) {
  211. return moment(time).format("YYYY-MM-DD HH:mm");
  212. };
  213. //新增数据
  214. $scope.addData = function () {
  215. $state.go("app.inspection.editor", {
  216. formKey: "inspectionform",
  217. service: "api_bpm_data",
  218. });
  219. };
  220. $scope.inspectdata = {};
  221. //跳转到编辑列表
  222. $scope.selectRowFunction = function (data) {
  223. var datas = delete data.item;
  224. datas = delete data.style;
  225. datas = delete data.runStatus;
  226. var filedata = {
  227. model: {
  228. incidentIntegral: data,
  229. },
  230. };
  231. $state.go("app.inspection.editor", {
  232. formKey: "inspectionform",
  233. service: "api_bpm_data",
  234. model: JSON.stringify(filedata),
  235. });
  236. };
  237. // 批量审核liaomingming
  238. $scope.batchReview = function(){
  239. SweetAlert.swal({
  240. title: "提示",
  241. text: "您是需要批量审核通过吗?",
  242. type: "warning",
  243. showCancelButton: true,
  244. confirmButtonColor: "#DD6B55",
  245. confirmButtonText: "确认",
  246. cancelButtonText: "取消",
  247. closeOnConfirm: true,
  248. closeOnCancel: true
  249. }, function (isConfirm) {
  250. if (isConfirm) {
  251. console.log($scope.selected.items);
  252. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  253. var auditState = res.find(v=>v.value == 1);
  254. var postData = angular.copy($scope.selected.items);
  255. postData.forEach(v=>{
  256. v.auditState = auditState;
  257. })
  258. api_simple.addListData('incidentIntegral', postData).then(function (response) {
  259. console.log(response)
  260. if (response.status == 200) {
  261. SweetAlert.swal({
  262. title: "审核通过!",
  263. confirmButtonColor: "#007AFF",
  264. type: "success"
  265. });
  266. $scope.refreshData('expand-right', $scope.fileData);
  267. } else {
  268. SweetAlert.swal({
  269. title: "操作失败",
  270. text: "操作失败, 请稍后再试!",
  271. type: "error"
  272. });
  273. }
  274. });
  275. })
  276. }
  277. });
  278. }
  279. //跳转到查看列表
  280. $scope.seeFunction = function (data) {
  281. var filedata = {
  282. model: {
  283. incidentIntegral: data,
  284. },
  285. };
  286. $state.go("app.inspection.form", {
  287. formKey: "inspection__detailform",
  288. service: "api_bpm_data",
  289. model: JSON.stringify(filedata),
  290. });
  291. };
  292. //跳转到查看列表
  293. $scope.lookFunction = function (data) {
  294. var filedata = {
  295. model: {
  296. incidentIntegral: data,
  297. },
  298. };
  299. $state.go("app.inspection.form", {
  300. formKey: "inspection__detailform",
  301. service: "api_bpm_data",
  302. model: JSON.stringify(filedata),
  303. });
  304. };
  305. //巡检暂停/恢复
  306. $scope.runFunction = function (data) {
  307. var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  308. var upData = {};
  309. upData.id = data.id;
  310. upData.operation = 1;
  311. var modalInstance = $modal.open({
  312. // templateUrl: 'assets/views/inspect/changRun.html',
  313. templateUrl: "assets/views/delete.html",
  314. // size: "sm",
  315. controller: function ($scope, $modalInstance) {
  316. $scope.isRunFunction = true;
  317. var status = "";
  318. if (data.status.name == "正常") {
  319. $scope.title = "暂停巡检计划";
  320. $scope.connect = "确定要暂停该巡检计划?";
  321. // $scope.textLog = "是否暂停该巡检计划";
  322. } else if (data.status.name == "停止") {
  323. $scope.title = "开始巡检计划";
  324. $scope.connect = "确定要开始该巡检计划?";
  325. // $scope.textLog = "是否开始该巡检计划";
  326. }
  327. $scope.ok = function () {
  328. // var groupdata = "123";
  329. // $modalInstance.dismiss('cancel');
  330. if (data.status.name == "正常") {
  331. upData.status = "停止";
  332. // data.style = "fa fa-pause";
  333. } else if (data.status.name == "停止") {
  334. upData.status = "正常";
  335. // data.style = "fa fa-play";
  336. }
  337. sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
  338. // $modalInstance.close(upData);
  339. $modalInstance.close(data);
  340. };
  341. $scope.cancel = function () {
  342. $modalInstance.dismiss("cancel");
  343. };
  344. },
  345. size: "sm",
  346. });
  347. modalInstance.result.then(function (result) {
  348. if (result) {
  349. // if(result.status=="停止"){
  350. // result.status={"id":$scope.statusData[1].id}
  351. // }else{
  352. // result.status={"id":$scope.statusData[2].id}
  353. // }
  354. // var upData = {
  355. // "inspection":{
  356. // "id": result.id,
  357. // "operation": result.operation,
  358. // "status": result.status
  359. // }
  360. // };
  361. if (result.status.value == "1") {
  362. result.status.id = $scope.statusData[1].id;
  363. } else if (result.status.value == "2") {
  364. result.status.id = $scope.statusData[0].id;
  365. }
  366. var toData = {
  367. inspection: result,
  368. };
  369. api_bpm_data.updData("inspection", toData).then(
  370. function (response) {
  371. var myData = Restangular.stripRestangular(response);
  372. if (myData.status == 200) {
  373. var showData = {
  374. idx: filterData.idx,
  375. sum: filterData.sum,
  376. inspection: {
  377. inspectionTypeDTO: {
  378. id: "",
  379. },
  380. },
  381. };
  382. if (
  383. filterData.inspection &&
  384. filterData.inspection.inspectionTypeDTO &&
  385. filterData.inspection.inspectionTypeDTO.id
  386. ) {
  387. showData.inspection.inspectionTypeDTO.id =
  388. filterData.inspection.inspectionTypeDTO.id;
  389. } else {
  390. showData.inspection.inspectionTypeDTO.id = -1;
  391. }
  392. $scope.refreshData("expand-right", $scope.fileData);
  393. }
  394. },
  395. function () {
  396. // $scope.ldloading[style.replace('-', '_')] = false;
  397. }
  398. );
  399. }
  400. });
  401. };
  402. // $scope.newincident = function(data) {
  403. // $state.go('app.incident.editor', {});
  404. // };
  405. //行删除
  406. $scope.removeData = function () {
  407. console.log($scope.selected.items);
  408. var modalInstance = $modal.open({
  409. templateUrl: "assets/views/delete.html",
  410. controller: function ($scope, $modalInstance) {
  411. // $scope.textLog = "是否删除巡检计划";
  412. $scope.title = "巡检计划删除";
  413. $scope.connect = "确定要删除巡检计划?";
  414. $scope.ok = function () {
  415. $modalInstance.close("start");
  416. };
  417. $scope.cancel = function () {
  418. $modalInstance.dismiss("cancel");
  419. };
  420. },
  421. size: "sm",
  422. });
  423. modalInstance.result.then(
  424. function (result) {
  425. if (result) {
  426. if ($scope.selected.items.length != 0) {
  427. $rootScope.isMask = true;
  428. }
  429. var rmvList = [];
  430. angular.forEach($scope.selected.items, function (item) {
  431. rmvList.push(item.id);
  432. });
  433. if (rmvList.length > 0) {
  434. api_bpm_data
  435. .rmvData("inspection", rmvList)
  436. .then(function (response) {
  437. if (response.status == 200) {
  438. $rootScope.isMask = false;
  439. SweetAlert.swal(
  440. {
  441. title: "删除成功!",
  442. type: "success",
  443. confirmButtonColor: "#007AFF",
  444. },
  445. function () {
  446. $scope.myData = _.reject($scope.myData, function (o) {
  447. return _.includes(rmvList, o.id);
  448. });
  449. $scope.selected = {
  450. items: [],
  451. };
  452. }
  453. );
  454. $scope.gridApi.selection.clearSelectedRows();
  455. var filterData = JSON.parse(
  456. sessionStorage.inspectPlanParameter
  457. );
  458. var showData = {
  459. idx: filterData.idx,
  460. sum: filterData.sum,
  461. inspection: {
  462. inspectionTypeDTO: {
  463. id: "",
  464. },
  465. },
  466. };
  467. if (
  468. filterData.inspection &&
  469. filterData.inspection.inspectionTypeDTO &&
  470. filterData.inspection.inspectionTypeDTO.id
  471. ) {
  472. showData.inspection.inspectionTypeDTO.id =
  473. filterData.inspection.inspectionTypeDTO.id;
  474. } else {
  475. showData.inspection.inspectionTypeDTO.id = -1;
  476. }
  477. $scope.refreshData("expand-right", $scope.fileData);
  478. //取消遮罩层
  479. // $scope.isMask = false;
  480. } else {
  481. $rootScope.isMask = false;
  482. SweetAlert.swal({
  483. title: "操作异常!",
  484. text: "系统异常,请稍后重试,或者联系管理员!",
  485. type: "error",
  486. });
  487. }
  488. });
  489. }
  490. }
  491. },
  492. function () {
  493. // $scope.ldloading[style.replace('-', '_')] = false;
  494. }
  495. );
  496. };
  497. $scope.selected = {
  498. items: [],
  499. };
  500. $scope.editted = {
  501. items: [],
  502. };
  503. $scope.testRow = [];
  504. $scope.gridOptions.onRegisterApi = function (gridApi) {
  505. //导入gridApi对象
  506. $scope.gridApi = gridApi;
  507. //分页选项
  508. gridApi.pagination.on.paginationChanged(
  509. $scope,
  510. function (newPage, pageSize) {
  511. var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  512. var filtersData = {};
  513. filtersData.idx = newPage - 1;
  514. filtersData.sum = pageSize;
  515. $scope.pageNum = $scope.gridApi.pagination.getPage() - 1;
  516. // console.log(pp);
  517. filterData.idx = $scope.pageNum;
  518. $scope.fileData.idx = newPage - 1;
  519. $scope.fileData.sum = pageSize;
  520. sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
  521. $scope.refreshData("expand-right", $scope.fileData);
  522. }
  523. );
  524. //勾选行事件
  525. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  526. if (data.isSelected) {
  527. $scope.selected.items.push(data.entity);
  528. } else {
  529. //objs:需要遍历的集合 data:遍历时当前的数据 index:遍历时当前索引
  530. //array:需要遍历的集合,每次遍历时都会把objs原样的传一次。
  531. //angular.forEach(objs, function(data,index,array)
  532. angular.forEach(
  533. $scope.selected.items,
  534. function (ObjIndex, index, destObj) {
  535. // console.log(ObjIndex);
  536. // console.log(index);
  537. // console.log(destObj);
  538. if (ObjIndex.id == data.entity.id) {
  539. destObj.splice(index, 1);
  540. }
  541. }
  542. );
  543. }
  544. });
  545. //批量全选
  546. gridApi.selection.on.rowSelectionChangedBatch(
  547. $scope,
  548. function (rows, event) {
  549. // if ($scope.selected.items.length != 0) {
  550. // $scope.selected.items = [];
  551. angular.forEach(rows, function (ObjIndex, index, destObj) {
  552. if (ObjIndex.isSelected) {
  553. $scope.selected.items.push(ObjIndex.entity);
  554. } else {
  555. $scope.selected.items = [];
  556. // $scope.selected.items.splice(index, 1);
  557. }
  558. });
  559. // } else {
  560. // }
  561. // $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
  562. // if ($scope.selected.items.length == 0) {
  563. // $scope.selected.items = $scope.mySelectedRows;
  564. // } else if ($scope.mySelectedRows.length == 0) {
  565. // for (var i = 0; i < $scope.selected.items.length; i++) {
  566. // for (var j = 0; j < rows.length; j++) {
  567. // if ($scope.selected.items[i].id == rows[j].entity.id) {
  568. // $scope.selected.items.splice(i, 1);
  569. // }
  570. // }
  571. // }
  572. // } else {
  573. // angular.forEach($scope.mySelectedRows, function(item) {
  574. // $scope.selected.items.push(item);
  575. // });
  576. // }
  577. }
  578. );
  579. //列过滤事件
  580. gridApi.core.on.filterChanged($scope, function () {
  581. var grid = this.grid;
  582. var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  583. angular.forEach(grid.columns, function (item) {
  584. if (item.enableFiltering) {
  585. if (
  586. angular.isDefined(item.filters[0].term) &&
  587. item.filters[0].term != ""
  588. ) {
  589. if (angular.isUndefined(filterData["inspection"])) {
  590. filterData["inspection"] = {};
  591. }
  592. filterData["inspection"]["title"] = item.filters[0].term;
  593. }
  594. }
  595. });
  596. sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
  597. $scope.refreshData("expand-right", filterData);
  598. });
  599. };
  600. // //刷新按钮
  601. // $scope.reload = function() {
  602. // var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  603. // var showData = {
  604. // "idx": filterData.idx,
  605. // "sum": filterData.sum,
  606. // "inspection": {
  607. // "inspectionTypeDTO": {
  608. // "id": ""
  609. // }
  610. // }
  611. // }
  612. // if (filterData.inspection && filterData.inspection.inspectionTypeDTO && filterData.inspection.inspectionTypeDTO.id) {
  613. // showData.inspection.inspectionTypeDTO.id = filterData.inspection.inspectionTypeDTO.id
  614. // } else {
  615. // showData.inspection.inspectionTypeDTO.id = -1
  616. // }
  617. // $scope.refreshData('expand-right', showData);
  618. // }
  619. //审核
  620. $scope.toAudit = function (data) {
  621. $modal.open({
  622. templateUrl: 'assets/views/incident/tpl/toAudit.tpl.html',
  623. controller: function ($scope, scope, $modalInstance, modelData, currentUserId, Alert, api_wechatfile,api_bpm_data) {
  624. $scope.msg = `由${data.handlerUserName}处理的事件由工时${data.sourceScore}改为工时${data.currentScore},发起原因为:${data.updateReason||''}`;
  625. $scope.ok = function () {
  626. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  627. var auditState = res.find(v=>v.value == 1);
  628. var postData = {
  629. incidentIntegral: {
  630. id:modelData.id,
  631. incidentId:modelData.incidentId,
  632. auditState:auditState,
  633. handlerUser:modelData.handlerUser,
  634. handlerUserName:modelData.handlerUserName,
  635. sourceScore:modelData.sourceScore,
  636. currentScore:modelData.currentScore,
  637. updateReason:modelData.updateReason||undefined,
  638. }
  639. }
  640. $modalInstance.close('success');
  641. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  642. console.log(response)
  643. if (response.status == 200) {
  644. Alert.swal({
  645. title: "审核通过!",
  646. confirmButtonColor: "#007AFF",
  647. type: "success"
  648. });
  649. scope.refreshData('expand-right', $scope.fileData);
  650. } else {
  651. Alert.swal({
  652. title: "操作失败",
  653. text: "操作失败, 请稍后再试!",
  654. type: "error"
  655. });
  656. }
  657. });
  658. })
  659. }
  660. // 调整工时
  661. $scope.time = function(){
  662. $modalInstance.close('success');
  663. $modal.open({
  664. templateUrl: 'assets/views/incident/tpl/toAuditTime.tpl.html',
  665. controller: function ($scope, $modalInstance, modelData, currentUserId, Alert,api_wechatfile,api_bpm_data) {
  666. console.log(modelData,loginUser);
  667. $scope.searchList = {time:''};
  668. $scope.list = [];
  669. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  670. $scope.list = res;
  671. })
  672. $scope.ok = function () {
  673. if (!$scope.searchList.time){
  674. Alert.swal({
  675. title: "操作失败",
  676. text: "请填写工时!",
  677. type: "error"
  678. });
  679. return;
  680. }
  681. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  682. var auditState = res.find(v=>v.value == 1);
  683. var postData = {
  684. incidentIntegral: {
  685. id:modelData.id,
  686. incidentId:modelData.incidentId,
  687. auditState:auditState,
  688. handlerUser:modelData.handlerUser,
  689. handlerUserName:modelData.handlerUserName,
  690. sourceScore:modelData.sourceScore,
  691. currentScore:modelData.currentScore,
  692. updateReason:modelData.updateReason||undefined,
  693. }
  694. }
  695. $modalInstance.close('success');
  696. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  697. console.log(response)
  698. if (response.status == 200) {
  699. Alert.swal({
  700. title: "审核通过!",
  701. confirmButtonColor: "#007AFF",
  702. type: "success"
  703. });
  704. scope.refreshData('expand-right', $scope.fileData);
  705. } else {
  706. Alert.swal({
  707. title: "操作失败",
  708. text: "操作失败, 请稍后再试!",
  709. type: "error"
  710. });
  711. }
  712. });
  713. })
  714. }
  715. $scope.cancel = function () {
  716. $modalInstance.dismiss('cancel');
  717. }
  718. },
  719. size: 'sm',
  720. resolve: {
  721. modelData: function () {
  722. return data;
  723. },
  724. currentUserId: function () {
  725. return loginUser.id;
  726. },
  727. Alert: function () {
  728. return SweetAlert;
  729. },
  730. api_wechatfile: function () {
  731. return api_wechatfile;
  732. },
  733. api_bpm_data: function () {
  734. return api_bpm_data;
  735. },
  736. }
  737. });
  738. }
  739. $scope.cancel = function () {
  740. $modalInstance.dismiss('cancel');
  741. }
  742. },
  743. size: 'sm',
  744. resolve: {
  745. scope: function () {
  746. return $scope;
  747. },
  748. modelData: function () {
  749. return data;
  750. },
  751. currentUserId: function () {
  752. return loginUser.id;
  753. },
  754. Alert: function () {
  755. return SweetAlert;
  756. },
  757. api_wechatfile: function () {
  758. return api_wechatfile;
  759. },
  760. api_bpm_data: function () {
  761. return api_bpm_data;
  762. }
  763. }
  764. });
  765. };
  766. //查看
  767. $scope.toDetail = function (data) {
  768. console.log(data,$rootScope.isFuwutai);
  769. if($rootScope.isFuwutai){
  770. //角色是服务台人员
  771. $state.go('app.incident.detail', {
  772. formKey: 'incident_back',
  773. pdKey: 'incident',
  774. dataId: data.id,
  775. taskId: data.taskId,
  776. processInstanceId: data.processInstanceId
  777. });
  778. }else{
  779. window.open(location.origin+'/#/app/incident/detail/incident_back/incident/'+data.id+'/'+data.taskId+'/'+data.processInstanceId+'//');
  780. }
  781. };
  782. //重置按钮
  783. $scope.reload = function () {
  784. // var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  785. // var data={
  786. // "idx":filterData.idx,
  787. // "sum":filterData.sum
  788. // }
  789. // $scope.inspectdata={};
  790. if(!$scope.isIncidentManager){
  791. $scope.fileData.incidentIntegral = {handlerUser:$rootScope.user.id}
  792. }else{
  793. $scope.fileData.incidentIntegral = {};
  794. }
  795. $scope.try_async_load();
  796. $scope.refreshData("expand-right", $scope.fileData);
  797. };
  798. //数据刷新
  799. $scope.refreshData = function (style, filterData) {
  800. $scope.ldloading[style.replace("-", "_")] = true;
  801. if (angular.isUndefined(filterData)) {
  802. filterData = defaultFilterData;
  803. }
  804. $scope.myData = [];
  805. var filterDataClone = angular.copy(filterData)
  806. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.startTime){
  807. filterDataClone.incidentIntegral.startTime = moment(filterDataClone.incidentIntegral.startTime).format('YYYY-MM-DD 00:00:00');
  808. }
  809. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.endTime){
  810. filterDataClone.incidentIntegral.endTime = moment(filterDataClone.incidentIntegral.endTime).format('YYYY-MM-DD 23:59:59');
  811. }
  812. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.handlerUser){
  813. filterDataClone.incidentIntegral.handlerUser = filterDataClone.incidentIntegral.handlerUser.id;
  814. }
  815. if(!$scope.isIncidentManager){
  816. filterDataClone.incidentIntegral.handlerUser = $rootScope.user.id;
  817. }
  818. api_bpm_data.fetchDataList("incidentIntegral", filterDataClone).then(
  819. function (data) {
  820. var myData = Restangular.stripRestangular(data);
  821. $scope.gridOptions.totalItems = myData.totalNum;
  822. if (angular.isArray(myData.list)) {
  823. $scope.myData = myData.list;
  824. for (var i = 0; i < $scope.myData.length; i++) {
  825. $scope.myData[i]["item"] =
  826. i + 1 + filterData.idx * filterData.sum;
  827. if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
  828. $scope.myData[i].percent = (
  829. ($scope.myData[i].completed * 100) /
  830. ($scope.myData[i].doing + $scope.myData[i].completed)
  831. ).toFixed(1);
  832. } else if ($scope.myData[i].completed == 0) {
  833. $scope.myData[i].percent = "0.0";
  834. } else {
  835. $scope.myData[i].percent = "0.0";
  836. }
  837. }
  838. console.log($scope.myData);
  839. for (var i = 0; i < $scope.myData.length; i++) {
  840. if ($scope.myData[i].status == "正常") {
  841. $scope.myData[i].style = "fa fa-play";
  842. } else if ($scope.myData[i].status == "停止") {
  843. $scope.myData[i].style = "fa fa-pause";
  844. }
  845. $scope.myData[i].runStatus = $scope.transfer(
  846. $scope.myData[i].status
  847. );
  848. }
  849. } else {
  850. SweetAlert.swal({
  851. title: "数据为空",
  852. text: myData.data,
  853. type: "warning",
  854. });
  855. }
  856. $scope.ldloading[style.replace("-", "_")] = false;
  857. },
  858. function () {
  859. $scope.ldloading[style.replace("-", "_")] = false;
  860. }
  861. );
  862. };
  863. $scope.refreshData2 = function (style, filterData) {
  864. $scope.ldloading[style.replace("-", "_")] = true;
  865. if (angular.isUndefined(filterData)) {
  866. filterData = defaultFilterData;
  867. }
  868. var filterDataClone = angular.copy(filterData)
  869. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.startTime){
  870. filterDataClone.incidentIntegral.startTime = moment(filterDataClone.incidentIntegral.startTime).format('YYYY-MM-DD 00:00:00');
  871. }
  872. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.endTime){
  873. filterDataClone.incidentIntegral.endTime = moment(filterDataClone.incidentIntegral.endTime).format('YYYY-MM-DD 23:59:59');
  874. }
  875. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.handlerUser){
  876. filterDataClone.incidentIntegral.handlerUser = filterDataClone.incidentIntegral.handlerUser.id;
  877. }
  878. if(!$scope.isIncidentManager){
  879. filterDataClone.incidentIntegral.handlerUser = $rootScope.user.id;
  880. }
  881. // $scope.myData = [];
  882. api_bpm_data.fetchDataList("incidentIntegral", filterDataClone).then(
  883. function (data) {
  884. var myData = Restangular.stripRestangular(data);
  885. $scope.gridOptions.totalItems = myData.totalNum;
  886. if (angular.isArray(myData.list)) {
  887. $scope.myData = myData.list;
  888. for (var i = 0; i < $scope.myData.length; i++) {
  889. $scope.myData[i]["item"] =
  890. i + 1 + filterData.idx * filterData.sum;
  891. if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
  892. $scope.myData[i].percent = (
  893. ($scope.myData[i].completed * 100) /
  894. ($scope.myData[i].doing + $scope.myData[i].completed)
  895. ).toFixed(1);
  896. } else if ($scope.myData[i].completed == 0) {
  897. $scope.myData[i].percent = "0.0";
  898. } else {
  899. $scope.myData[i].percent = "0.0";
  900. }
  901. }
  902. console.log($scope.myData);
  903. for (var i = 0; i < $scope.myData.length; i++) {
  904. if ($scope.myData[i].status == "正常") {
  905. $scope.myData[i].style = "fa fa-play";
  906. } else if ($scope.myData[i].status == "停止") {
  907. $scope.myData[i].style = "fa fa-pause";
  908. }
  909. $scope.myData[i].runStatus = $scope.transfer(
  910. $scope.myData[i].status
  911. );
  912. }
  913. } else {
  914. SweetAlert.swal({
  915. title: "数据为空",
  916. text: myData.data,
  917. type: "warning",
  918. });
  919. }
  920. $scope.ldloading[style.replace("-", "_")] = false;
  921. },
  922. function () {
  923. $scope.ldloading[style.replace("-", "_")] = false;
  924. }
  925. );
  926. };
  927. $scope.ldloading = {};
  928. //树形控件点击事件
  929. $scope.my_tree_handler = function (branch) {
  930. var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  931. filterData.inspection.inspectionTypeDTO.id = branch.id;
  932. sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
  933. var showData = {
  934. idx: filterData.id,
  935. sum: filterData.sum,
  936. inspection: {
  937. inspectionTypeDTO: {
  938. id: branch.id,
  939. },
  940. },
  941. };
  942. // $scope.refreshData('expand-right', showData);
  943. };
  944. $scope.fileData = {
  945. idx: 0,
  946. sum: 10,
  947. incidentIntegral: {},
  948. };
  949. $scope.onFilterCallback = function (data) {
  950. $scope.fileData.inspection.inspectionTypeDTO = {
  951. id: data.id,
  952. };
  953. };
  954. $scope.inspecttype = {};
  955. $scope.searchinspe = function (item) {
  956. $scope.refreshData("expand-right", $scope.fileData);
  957. };
  958. //树形控件加载
  959. $scope.my_tree = {};
  960. $scope.try_async_load = function () {
  961. $scope.my_data = [];
  962. $scope.doing_async = true;
  963. api_bpm_data
  964. .fetchDataList("inspectionType", {
  965. idx: 0,
  966. sum: 1000,
  967. })
  968. .then(function (response) {
  969. if (response.status == 200) {
  970. var data = response.list;
  971. var objects = [];
  972. for (var i = 0; i < data.length; i++) {
  973. var object = {};
  974. object.id = data[i].id;
  975. if (data[i].parent && data[i].parent.id != 0) {
  976. object.parent = data[i].parent.id;
  977. }
  978. object.label = data[i].type;
  979. objects.push(object);
  980. }
  981. $scope.my_data = convertParentToChildList(objects);
  982. $scope.tree_data = angular.copy($scope.my_data);
  983. if ($scope.my_data.length > 0) {
  984. $scope.doing_async = false;
  985. }
  986. // return $scope.my_tree.expand_all()
  987. } else {
  988. SweetAlert.swal({
  989. title: "系统错误!",
  990. text: "请刷新重试!",
  991. type: "error",
  992. });
  993. }
  994. });
  995. };
  996. function convertListToTree(data, treeMap) {
  997. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  998. var root = null; //Initially set our loop to null
  999. var parentNode = null;
  1000. //loop over data
  1001. for (var i = 0; i < data.length; i++) {
  1002. var datum = data[i];
  1003. //each node will have children, so let's give it a "children" poperty
  1004. datum.children = [];
  1005. //add an entry for this node to the map so that any future children can
  1006. //lookup the parent
  1007. idToNodeMap[datum.id] = datum;
  1008. //Does this node have a parent?
  1009. if (typeof datum.parent === "undefined" || datum.parent == null) {
  1010. //Doesn't look like it, so this node is the root of the tree
  1011. root = datum;
  1012. treeMap[datum.id] = root;
  1013. } else {
  1014. //This node has a parent, so let's look it up using the id
  1015. parentNode = idToNodeMap[datum.parent];
  1016. //We don't need this property, so let's delete it.
  1017. delete datum.parent;
  1018. //Let's add the current node as a child of the parent node.
  1019. parentNode.children.push(datum);
  1020. }
  1021. }
  1022. return root;
  1023. }
  1024. // 获取状态
  1025. $scope.getStatusDictroy = function () {
  1026. var data = {
  1027. key: "incident_integral_state",
  1028. type: "list",
  1029. };
  1030. api_wechatfile.getDictionary(data).then(function (res) {
  1031. $scope.statusData = res;
  1032. });
  1033. };
  1034. $scope.getStatusDictroy();
  1035. // 获取执行人
  1036. $scope.getExecuteUser = function () {
  1037. api_configure_data
  1038. .fetchDataList("user", {
  1039. idx: 0,
  1040. sum: 1000,
  1041. user: {
  1042. roledata: {
  1043. rolecode: "inspectman",
  1044. },
  1045. simple: true,
  1046. engineer: 1,
  1047. },
  1048. })
  1049. .then(function (res) {
  1050. $scope.executeUserData = res.list;
  1051. });
  1052. };
  1053. $scope.getExecuteUser();
  1054. // 获取处理人
  1055. $scope.getCreateUser = function (keyword = '') {
  1056. api_configure_data
  1057. .fetchDataList("user", {
  1058. idx: 0,
  1059. sum: 1000,
  1060. "user": {
  1061. "name": keyword,
  1062. 'selectType': "pinyin_qs",
  1063. engineer: 1,
  1064. }
  1065. })
  1066. .then(function (res) {
  1067. $scope.createUserData = res.list;
  1068. });
  1069. };
  1070. $scope.getCreateUser();
  1071. $scope.open = function ($event) {
  1072. $event.preventDefault();
  1073. $event.stopPropagation();
  1074. $scope.opened = !$scope.opened;
  1075. };
  1076. $scope.endOpen = function ($event) {
  1077. $event.preventDefault();
  1078. $event.stopPropagation();
  1079. $scope.startOpened = false;
  1080. $scope.endOpened = !$scope.endOpened;
  1081. };
  1082. $scope.startOpen = function ($event) {
  1083. $event.preventDefault();
  1084. $event.stopPropagation();
  1085. $scope.endOpened = false;
  1086. $scope.startOpened = !$scope.startOpened;
  1087. };
  1088. function convertParentToChildList(data) {
  1089. var treeMap = {};
  1090. var list = [];
  1091. convertListToTree(data, treeMap);
  1092. angular.forEach(treeMap, function (item) {
  1093. list.push(item);
  1094. });
  1095. return list;
  1096. }
  1097. $scope.refresh = function () {
  1098. var jry_filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  1099. var intervalData = {};
  1100. if ($scope.inspectdata.type) {
  1101. $scope.inspectdata.inspectionTypeDTO = $scope.inspectdata.type.id;
  1102. }
  1103. if ($scope.inspectdata.createTime) {
  1104. $scope.inspectdata.createTime = moment(
  1105. $scope.inspectdata.createTime
  1106. ).format("YYYY-MM-DD");
  1107. }
  1108. intervalData.idx = jry_filterData.idx;
  1109. intervalData.sum = jry_filterData.sum;
  1110. intervalData.inspection = $scope.inspectdata;
  1111. $scope.refreshData("expand-right", intervalData);
  1112. };
  1113. $scope.try_async_load();
  1114. $scope.refreshData("expand-right", $scope.fileData);
  1115. $scope.timer = $interval(function () {
  1116. $scope.refreshData2("expand-right", $scope.fileData);
  1117. }, $rootScope.refreshTime);
  1118. $scope.$on("$destroy", function () {
  1119. $interval.cancel($scope.timer);
  1120. });
  1121. },
  1122. ]);
  1123. app.factory("inspectListMobileCtrlTree", [
  1124. "api_bpm_data",
  1125. function (api_bpm_data) {
  1126. function convertListToTree(data, treeMap) {
  1127. var idToNodeMap = {};
  1128. var root = null;
  1129. var parentNode = null;
  1130. for (var i = 0; i < data.length; i++) {
  1131. var datum = data[i];
  1132. datum.children = [];
  1133. idToNodeMap[datum.id] = datum;
  1134. if (typeof datum.parent === "undefined" || datum.parent == null) {
  1135. root = datum;
  1136. treeMap[datum.id] = root;
  1137. } else {
  1138. parentNode = idToNodeMap[datum.parent];
  1139. delete datum.parent;
  1140. parentNode.children.push(datum);
  1141. }
  1142. }
  1143. return root;
  1144. }
  1145. function convertParentToChildList(data) {
  1146. var treeMap = {};
  1147. var list = [];
  1148. convertListToTree(data, treeMap);
  1149. angular.forEach(treeMap, function (item) {
  1150. list.push(item);
  1151. });
  1152. return list;
  1153. }
  1154. var forEachEelement = function forEachEelement(response) {
  1155. var objects = [];
  1156. angular.forEach(response.list, function (ObjIndex, index, destObj) {
  1157. var object = {};
  1158. object.id = ObjIndex.id;
  1159. object.label = ObjIndex.type;
  1160. if (ObjIndex.parent && ObjIndex.parent.id != 0) {
  1161. object.parent = ObjIndex.parent.id;
  1162. }
  1163. if (ObjIndex.formUiEdit) {
  1164. object.formUiEdit = ObjIndex.formUiEdit;
  1165. }
  1166. if (ObjIndex.formUiName) {
  1167. object.formUiName = ObjIndex.formUiName;
  1168. }
  1169. if (ObjIndex.processKey) {
  1170. object.processKey = ObjIndex.processKey;
  1171. }
  1172. if (ObjIndex.formUiStart) {
  1173. object.formUiStart = ObjIndex.formUiStart;
  1174. }
  1175. objects.push(object);
  1176. });
  1177. var my_data = convertParentToChildList(objects);
  1178. var tree_data = angular.copy(my_data);
  1179. return {
  1180. my_data: my_data,
  1181. tree_data: tree_data,
  1182. };
  1183. };
  1184. return forEachEelement;
  1185. },
  1186. ]);