integralCtrl.js 36 KB

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