integralCtrl.js 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  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. },
  1047. })
  1048. .then(function (res) {
  1049. $scope.executeUserData = res.list;
  1050. });
  1051. };
  1052. $scope.getExecuteUser();
  1053. // 获取处理人
  1054. $scope.getCreateUser = function (keyword = '') {
  1055. api_configure_data
  1056. .fetchDataList("user", {
  1057. idx: 0,
  1058. sum: 1000,
  1059. "user": {
  1060. "name": keyword,
  1061. 'selectType': "pinyin_qs"
  1062. }
  1063. })
  1064. .then(function (res) {
  1065. $scope.createUserData = res.list;
  1066. });
  1067. };
  1068. $scope.getCreateUser();
  1069. $scope.open = function ($event) {
  1070. $event.preventDefault();
  1071. $event.stopPropagation();
  1072. $scope.opened = !$scope.opened;
  1073. };
  1074. $scope.endOpen = function ($event) {
  1075. $event.preventDefault();
  1076. $event.stopPropagation();
  1077. $scope.startOpened = false;
  1078. $scope.endOpened = !$scope.endOpened;
  1079. };
  1080. $scope.startOpen = function ($event) {
  1081. $event.preventDefault();
  1082. $event.stopPropagation();
  1083. $scope.endOpened = false;
  1084. $scope.startOpened = !$scope.startOpened;
  1085. };
  1086. function convertParentToChildList(data) {
  1087. var treeMap = {};
  1088. var list = [];
  1089. convertListToTree(data, treeMap);
  1090. angular.forEach(treeMap, function (item) {
  1091. list.push(item);
  1092. });
  1093. return list;
  1094. }
  1095. $scope.refresh = function () {
  1096. var jry_filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  1097. var intervalData = {};
  1098. if ($scope.inspectdata.type) {
  1099. $scope.inspectdata.inspectionTypeDTO = $scope.inspectdata.type.id;
  1100. }
  1101. if ($scope.inspectdata.createTime) {
  1102. $scope.inspectdata.createTime = moment(
  1103. $scope.inspectdata.createTime
  1104. ).format("YYYY-MM-DD");
  1105. }
  1106. intervalData.idx = jry_filterData.idx;
  1107. intervalData.sum = jry_filterData.sum;
  1108. intervalData.inspection = $scope.inspectdata;
  1109. $scope.refreshData("expand-right", intervalData);
  1110. };
  1111. $scope.try_async_load();
  1112. $scope.refreshData("expand-right", $scope.fileData);
  1113. $scope.timer = $interval(function () {
  1114. $scope.refreshData2("expand-right", $scope.fileData);
  1115. }, $rootScope.refreshTime);
  1116. $scope.$on("$destroy", function () {
  1117. $interval.cancel($scope.timer);
  1118. });
  1119. },
  1120. ]);
  1121. app.factory("inspectListMobileCtrlTree", [
  1122. "api_bpm_data",
  1123. function (api_bpm_data) {
  1124. function convertListToTree(data, treeMap) {
  1125. var idToNodeMap = {};
  1126. var root = null;
  1127. var parentNode = null;
  1128. for (var i = 0; i < data.length; i++) {
  1129. var datum = data[i];
  1130. datum.children = [];
  1131. idToNodeMap[datum.id] = datum;
  1132. if (typeof datum.parent === "undefined" || datum.parent == null) {
  1133. root = datum;
  1134. treeMap[datum.id] = root;
  1135. } else {
  1136. parentNode = idToNodeMap[datum.parent];
  1137. delete datum.parent;
  1138. parentNode.children.push(datum);
  1139. }
  1140. }
  1141. return root;
  1142. }
  1143. function convertParentToChildList(data) {
  1144. var treeMap = {};
  1145. var list = [];
  1146. convertListToTree(data, treeMap);
  1147. angular.forEach(treeMap, function (item) {
  1148. list.push(item);
  1149. });
  1150. return list;
  1151. }
  1152. var forEachEelement = function forEachEelement(response) {
  1153. var objects = [];
  1154. angular.forEach(response.list, function (ObjIndex, index, destObj) {
  1155. var object = {};
  1156. object.id = ObjIndex.id;
  1157. object.label = ObjIndex.type;
  1158. if (ObjIndex.parent && ObjIndex.parent.id != 0) {
  1159. object.parent = ObjIndex.parent.id;
  1160. }
  1161. if (ObjIndex.formUiEdit) {
  1162. object.formUiEdit = ObjIndex.formUiEdit;
  1163. }
  1164. if (ObjIndex.formUiName) {
  1165. object.formUiName = ObjIndex.formUiName;
  1166. }
  1167. if (ObjIndex.processKey) {
  1168. object.processKey = ObjIndex.processKey;
  1169. }
  1170. if (ObjIndex.formUiStart) {
  1171. object.formUiStart = ObjIndex.formUiStart;
  1172. }
  1173. objects.push(object);
  1174. });
  1175. var my_data = convertParentToChildList(objects);
  1176. var tree_data = angular.copy(my_data);
  1177. return {
  1178. my_data: my_data,
  1179. tree_data: tree_data,
  1180. };
  1181. };
  1182. return forEachEelement;
  1183. },
  1184. ]);