integralCtrl.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  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.incidentDetail', {
  772. id: data.id,
  773. });
  774. }else{
  775. window.open(location.origin+'/#/app/incident/incidentDetail/'+data.id);
  776. }
  777. };
  778. //重置按钮
  779. $scope.reload = function () {
  780. // var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  781. // var data={
  782. // "idx":filterData.idx,
  783. // "sum":filterData.sum
  784. // }
  785. // $scope.inspectdata={};
  786. if(!$scope.isIncidentManager){
  787. $scope.fileData.incidentIntegral = {handlerUser:$rootScope.user.id}
  788. }else{
  789. $scope.fileData.incidentIntegral = {};
  790. }
  791. $scope.try_async_load();
  792. $scope.refreshData("expand-right", $scope.fileData);
  793. };
  794. //数据刷新
  795. $scope.refreshData = function (style, filterData) {
  796. $scope.ldloading[style.replace("-", "_")] = true;
  797. if (angular.isUndefined(filterData)) {
  798. filterData = defaultFilterData;
  799. }
  800. $scope.myData = [];
  801. var filterDataClone = angular.copy(filterData)
  802. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.startTime){
  803. filterDataClone.incidentIntegral.startTime = moment(filterDataClone.incidentIntegral.startTime).format('YYYY-MM-DD 00:00:00');
  804. }
  805. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.endTime){
  806. filterDataClone.incidentIntegral.endTime = moment(filterDataClone.incidentIntegral.endTime).format('YYYY-MM-DD 23:59:59');
  807. }
  808. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.handlerUser){
  809. filterDataClone.incidentIntegral.handlerUser = filterDataClone.incidentIntegral.handlerUser.id;
  810. }
  811. if(!$scope.isIncidentManager){
  812. filterDataClone.incidentIntegral.handlerUser = $rootScope.user.id;
  813. }
  814. api_bpm_data.fetchDataList("incidentIntegral", filterDataClone).then(
  815. function (data) {
  816. var myData = Restangular.stripRestangular(data);
  817. $scope.gridOptions.totalItems = myData.totalNum;
  818. if (angular.isArray(myData.list)) {
  819. $scope.myData = myData.list;
  820. for (var i = 0; i < $scope.myData.length; i++) {
  821. $scope.myData[i]["item"] =
  822. i + 1 + filterData.idx * filterData.sum;
  823. if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
  824. $scope.myData[i].percent = (
  825. ($scope.myData[i].completed * 100) /
  826. ($scope.myData[i].doing + $scope.myData[i].completed)
  827. ).toFixed(1);
  828. } else if ($scope.myData[i].completed == 0) {
  829. $scope.myData[i].percent = "0.0";
  830. } else {
  831. $scope.myData[i].percent = "0.0";
  832. }
  833. }
  834. console.log($scope.myData);
  835. for (var i = 0; i < $scope.myData.length; i++) {
  836. if ($scope.myData[i].status == "正常") {
  837. $scope.myData[i].style = "fa fa-play";
  838. } else if ($scope.myData[i].status == "停止") {
  839. $scope.myData[i].style = "fa fa-pause";
  840. }
  841. $scope.myData[i].runStatus = $scope.transfer(
  842. $scope.myData[i].status
  843. );
  844. }
  845. } else {
  846. SweetAlert.swal({
  847. title: "数据为空",
  848. text: myData.data,
  849. type: "warning",
  850. });
  851. }
  852. $scope.ldloading[style.replace("-", "_")] = false;
  853. },
  854. function () {
  855. $scope.ldloading[style.replace("-", "_")] = false;
  856. }
  857. );
  858. };
  859. $scope.refreshData2 = function (style, filterData) {
  860. $scope.ldloading[style.replace("-", "_")] = true;
  861. if (angular.isUndefined(filterData)) {
  862. filterData = defaultFilterData;
  863. }
  864. var filterDataClone = angular.copy(filterData)
  865. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.startTime){
  866. filterDataClone.incidentIntegral.startTime = moment(filterDataClone.incidentIntegral.startTime).format('YYYY-MM-DD 00:00:00');
  867. }
  868. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.endTime){
  869. filterDataClone.incidentIntegral.endTime = moment(filterDataClone.incidentIntegral.endTime).format('YYYY-MM-DD 23:59:59');
  870. }
  871. if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.handlerUser){
  872. filterDataClone.incidentIntegral.handlerUser = filterDataClone.incidentIntegral.handlerUser.id;
  873. }
  874. if(!$scope.isIncidentManager){
  875. filterDataClone.incidentIntegral.handlerUser = $rootScope.user.id;
  876. }
  877. // $scope.myData = [];
  878. api_bpm_data.fetchDataList("incidentIntegral", filterDataClone).then(
  879. function (data) {
  880. var myData = Restangular.stripRestangular(data);
  881. $scope.gridOptions.totalItems = myData.totalNum;
  882. if (angular.isArray(myData.list)) {
  883. $scope.myData = myData.list;
  884. for (var i = 0; i < $scope.myData.length; i++) {
  885. $scope.myData[i]["item"] =
  886. i + 1 + filterData.idx * filterData.sum;
  887. if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
  888. $scope.myData[i].percent = (
  889. ($scope.myData[i].completed * 100) /
  890. ($scope.myData[i].doing + $scope.myData[i].completed)
  891. ).toFixed(1);
  892. } else if ($scope.myData[i].completed == 0) {
  893. $scope.myData[i].percent = "0.0";
  894. } else {
  895. $scope.myData[i].percent = "0.0";
  896. }
  897. }
  898. console.log($scope.myData);
  899. for (var i = 0; i < $scope.myData.length; i++) {
  900. if ($scope.myData[i].status == "正常") {
  901. $scope.myData[i].style = "fa fa-play";
  902. } else if ($scope.myData[i].status == "停止") {
  903. $scope.myData[i].style = "fa fa-pause";
  904. }
  905. $scope.myData[i].runStatus = $scope.transfer(
  906. $scope.myData[i].status
  907. );
  908. }
  909. } else {
  910. SweetAlert.swal({
  911. title: "数据为空",
  912. text: myData.data,
  913. type: "warning",
  914. });
  915. }
  916. $scope.ldloading[style.replace("-", "_")] = false;
  917. },
  918. function () {
  919. $scope.ldloading[style.replace("-", "_")] = false;
  920. }
  921. );
  922. };
  923. $scope.ldloading = {};
  924. //树形控件点击事件
  925. $scope.my_tree_handler = function (branch) {
  926. var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  927. filterData.inspection.inspectionTypeDTO.id = branch.id;
  928. sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
  929. var showData = {
  930. idx: filterData.id,
  931. sum: filterData.sum,
  932. inspection: {
  933. inspectionTypeDTO: {
  934. id: branch.id,
  935. },
  936. },
  937. };
  938. // $scope.refreshData('expand-right', showData);
  939. };
  940. $scope.fileData = {
  941. idx: 0,
  942. sum: 10,
  943. incidentIntegral: {},
  944. };
  945. $scope.onFilterCallback = function (data) {
  946. $scope.fileData.inspection.inspectionTypeDTO = {
  947. id: data.id,
  948. };
  949. };
  950. $scope.inspecttype = {};
  951. $scope.searchinspe = function (item) {
  952. $scope.refreshData("expand-right", $scope.fileData);
  953. };
  954. //树形控件加载
  955. $scope.my_tree = {};
  956. $scope.try_async_load = function () {
  957. $scope.my_data = [];
  958. $scope.doing_async = true;
  959. api_bpm_data
  960. .fetchDataList("inspectionType", {
  961. idx: 0,
  962. sum: 1000,
  963. })
  964. .then(function (response) {
  965. if (response.status == 200) {
  966. var data = response.list;
  967. var objects = [];
  968. for (var i = 0; i < data.length; i++) {
  969. var object = {};
  970. object.id = data[i].id;
  971. if (data[i].parent && data[i].parent.id != 0) {
  972. object.parent = data[i].parent.id;
  973. }
  974. object.label = data[i].type;
  975. objects.push(object);
  976. }
  977. $scope.my_data = convertParentToChildList(objects);
  978. $scope.tree_data = angular.copy($scope.my_data);
  979. if ($scope.my_data.length > 0) {
  980. $scope.doing_async = false;
  981. }
  982. // return $scope.my_tree.expand_all()
  983. } else {
  984. SweetAlert.swal({
  985. title: "系统错误!",
  986. text: "请刷新重试!",
  987. type: "error",
  988. });
  989. }
  990. });
  991. };
  992. function convertListToTree(data, treeMap) {
  993. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  994. var root = null; //Initially set our loop to null
  995. var parentNode = null;
  996. //loop over data
  997. for (var i = 0; i < data.length; i++) {
  998. var datum = data[i];
  999. //each node will have children, so let's give it a "children" poperty
  1000. datum.children = [];
  1001. //add an entry for this node to the map so that any future children can
  1002. //lookup the parent
  1003. idToNodeMap[datum.id] = datum;
  1004. //Does this node have a parent?
  1005. if (typeof datum.parent === "undefined" || datum.parent == null) {
  1006. //Doesn't look like it, so this node is the root of the tree
  1007. root = datum;
  1008. treeMap[datum.id] = root;
  1009. } else {
  1010. //This node has a parent, so let's look it up using the id
  1011. parentNode = idToNodeMap[datum.parent];
  1012. //We don't need this property, so let's delete it.
  1013. delete datum.parent;
  1014. //Let's add the current node as a child of the parent node.
  1015. parentNode.children.push(datum);
  1016. }
  1017. }
  1018. return root;
  1019. }
  1020. // 获取状态
  1021. $scope.getStatusDictroy = function () {
  1022. var data = {
  1023. key: "incident_integral_state",
  1024. type: "list",
  1025. };
  1026. api_wechatfile.getDictionary(data).then(function (res) {
  1027. $scope.statusData = res;
  1028. });
  1029. };
  1030. $scope.getStatusDictroy();
  1031. // 获取执行人
  1032. $scope.getExecuteUser = function () {
  1033. api_configure_data
  1034. .fetchDataList("user", {
  1035. idx: 0,
  1036. sum: 1000,
  1037. user: {
  1038. roledata: {
  1039. rolecode: "inspectman",
  1040. },
  1041. simple: true,
  1042. engineer: 1,
  1043. },
  1044. })
  1045. .then(function (res) {
  1046. $scope.executeUserData = res.list;
  1047. });
  1048. };
  1049. $scope.getExecuteUser();
  1050. // 获取处理人
  1051. $scope.getCreateUser = function (keyword = '') {
  1052. api_configure_data
  1053. .fetchDataList("user", {
  1054. idx: 0,
  1055. sum: 1000,
  1056. "user": {
  1057. "name": keyword,
  1058. 'selectType': "pinyin_qs",
  1059. engineer: 1,
  1060. }
  1061. })
  1062. .then(function (res) {
  1063. $scope.createUserData = res.list;
  1064. });
  1065. };
  1066. $scope.getCreateUser();
  1067. $scope.open = function ($event) {
  1068. $event.preventDefault();
  1069. $event.stopPropagation();
  1070. $scope.opened = !$scope.opened;
  1071. };
  1072. $scope.endOpen = function ($event) {
  1073. $event.preventDefault();
  1074. $event.stopPropagation();
  1075. $scope.startOpened = false;
  1076. $scope.endOpened = !$scope.endOpened;
  1077. };
  1078. $scope.startOpen = function ($event) {
  1079. $event.preventDefault();
  1080. $event.stopPropagation();
  1081. $scope.endOpened = false;
  1082. $scope.startOpened = !$scope.startOpened;
  1083. };
  1084. function convertParentToChildList(data) {
  1085. var treeMap = {};
  1086. var list = [];
  1087. convertListToTree(data, treeMap);
  1088. angular.forEach(treeMap, function (item) {
  1089. list.push(item);
  1090. });
  1091. return list;
  1092. }
  1093. $scope.refresh = function () {
  1094. var jry_filterData = JSON.parse(sessionStorage.inspectPlanParameter);
  1095. var intervalData = {};
  1096. if ($scope.inspectdata.type) {
  1097. $scope.inspectdata.inspectionTypeDTO = $scope.inspectdata.type.id;
  1098. }
  1099. if ($scope.inspectdata.createTime) {
  1100. $scope.inspectdata.createTime = moment(
  1101. $scope.inspectdata.createTime
  1102. ).format("YYYY-MM-DD");
  1103. }
  1104. intervalData.idx = jry_filterData.idx;
  1105. intervalData.sum = jry_filterData.sum;
  1106. intervalData.inspection = $scope.inspectdata;
  1107. $scope.refreshData("expand-right", intervalData);
  1108. };
  1109. $scope.try_async_load();
  1110. $scope.refreshData("expand-right", $scope.fileData);
  1111. $scope.timer = $interval(function () {
  1112. $scope.refreshData2("expand-right", $scope.fileData);
  1113. }, $rootScope.refreshTime);
  1114. $scope.$on("$destroy", function () {
  1115. $interval.cancel($scope.timer);
  1116. });
  1117. },
  1118. ]);
  1119. app.factory("inspectListMobileCtrlTree", [
  1120. "api_bpm_data",
  1121. function (api_bpm_data) {
  1122. function convertListToTree(data, treeMap) {
  1123. var idToNodeMap = {};
  1124. var root = null;
  1125. var parentNode = null;
  1126. for (var i = 0; i < data.length; i++) {
  1127. var datum = data[i];
  1128. datum.children = [];
  1129. idToNodeMap[datum.id] = datum;
  1130. if (typeof datum.parent === "undefined" || datum.parent == null) {
  1131. root = datum;
  1132. treeMap[datum.id] = root;
  1133. } else {
  1134. parentNode = idToNodeMap[datum.parent];
  1135. delete datum.parent;
  1136. parentNode.children.push(datum);
  1137. }
  1138. }
  1139. return root;
  1140. }
  1141. function convertParentToChildList(data) {
  1142. var treeMap = {};
  1143. var list = [];
  1144. convertListToTree(data, treeMap);
  1145. angular.forEach(treeMap, function (item) {
  1146. list.push(item);
  1147. });
  1148. return list;
  1149. }
  1150. var forEachEelement = function forEachEelement(response) {
  1151. var objects = [];
  1152. angular.forEach(response.list, function (ObjIndex, index, destObj) {
  1153. var object = {};
  1154. object.id = ObjIndex.id;
  1155. object.label = ObjIndex.type;
  1156. if (ObjIndex.parent && ObjIndex.parent.id != 0) {
  1157. object.parent = ObjIndex.parent.id;
  1158. }
  1159. if (ObjIndex.formUiEdit) {
  1160. object.formUiEdit = ObjIndex.formUiEdit;
  1161. }
  1162. if (ObjIndex.formUiName) {
  1163. object.formUiName = ObjIndex.formUiName;
  1164. }
  1165. if (ObjIndex.processKey) {
  1166. object.processKey = ObjIndex.processKey;
  1167. }
  1168. if (ObjIndex.formUiStart) {
  1169. object.formUiStart = ObjIndex.formUiStart;
  1170. }
  1171. objects.push(object);
  1172. });
  1173. var my_data = convertParentToChildList(objects);
  1174. var tree_data = angular.copy(my_data);
  1175. return {
  1176. my_data: my_data,
  1177. tree_data: tree_data,
  1178. };
  1179. };
  1180. return forEachEelement;
  1181. },
  1182. ]);