integralCtrl.js 36 KB

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