jry_emergencyCtrl.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988
  1. 'use strict';
  2. app.controller('jry_emergencyCtrl', ["$scope", "i18nService", "$rootScope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_data", "api_text", 'moment',
  3. function($scope, i18nService, $rootScope, $state, $timeout, $interval, $modal, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_data, api_text, moment) {
  4. console.log($scope);
  5. $scope.langs = i18nService.getAllLangs();
  6. $scope.lang = 'zh-cn';
  7. i18nService.setCurrentLang($scope.lang);
  8. // $(window).resize(function() {
  9. // // console.log("1111")
  10. // });
  11. var loginUser = $rootScope.user;
  12. // var voiceurl=$rootScope.audioiIp;
  13. // delete $rootScope.user.authority;
  14. var pdKey = $state.current.pdKey;
  15. $scope.gridOptions = {};
  16. $scope.gridOptions.data = 'myData';
  17. $scope.gridOptions.enableColumnResizing = true;
  18. $scope.gridOptions.enableFiltering = false;
  19. $scope.gridOptions.enableGridMenu = false;
  20. $scope.gridOptions.enableSelectAll = true;
  21. $scope.gridOptions.enableRowSelection = true;
  22. $scope.gridOptions.showGridFooter = true;
  23. $scope.gridOptions.showColumnFooter = false;
  24. $scope.gridOptions.fastWatch = true;
  25. $scope.gridOptions.enableSorting = true;
  26. $scope.gridOptions.useExternalSorting = true;
  27. $scope.gridOptions.useExternalFiltering = false;
  28. $scope.gridOptions.useExternalPagination = true;
  29. $scope.gridOptions.paginationPageSizes = [10, 15, 20, 50, 100];
  30. $scope.gridOptions.paginationPageSize = 15;
  31. $scope.gridOptions.multiSelect = true;
  32. var mun = $scope.gridOptions.paginationPageSize;
  33. // $scope.gridOptions.rowTemplate = "<div ng-click=\"lookFunction(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>";
  34. $scope.gridOptions.rowIdentity = function(row) {
  35. return row.id;
  36. };
  37. $scope.gridOptions.getRowIdentity = function(row) {
  38. return row.id;
  39. };
  40. $scope.gridOptions.columnDefs = [
  41. {
  42. name: 'item',
  43. displayName: '序号',
  44. width: 50,
  45. cellTemplate: '<div>' +
  46. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  47. '</div>'
  48. },
  49. {
  50. name: 'alarmSystem',
  51. displayName: '告警来源',
  52. width: '10%',
  53. cellTemplate: '<div>' +
  54. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.alarm.alarmSystem}}</div>' +
  55. '</div>'
  56. }, {
  57. name: 'incidentDescription',
  58. displayName: '告警内容',
  59. width: '20%',
  60. cellTemplate: '<div>' +
  61. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.alarm.alarmContent}}</div>' +
  62. '</div>'
  63. }, {
  64. name: 'requester.name',
  65. displayName: '告警类型',
  66. width: '8%',
  67. cellTemplate: '<div>' +
  68. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.alarm.alarmType}}</div>' +
  69. '</div>'
  70. }, {
  71. name: 'alarmStatus',
  72. displayName: '告警状态',
  73. width: '7%',
  74. cellTemplate: '<div>' +
  75. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.alarm.alarmStatus}}</div>' +
  76. '</div>'
  77. }, {
  78. name: 'state',
  79. displayName: '工单状态',
  80. width: '7%',
  81. cellTemplate: '<div>' +
  82. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.state}}</div>' +
  83. '</div>'
  84. }, {
  85. name: 'address',
  86. displayName: '定位',
  87. width: '10%',
  88. cellTemplate: '<div>' +
  89. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" > {{row.entity.alarm.alarmLocation}}</div>' +
  90. '</div>'
  91. }, {
  92. name: 'contactsInformation',
  93. displayName: '紧急度',
  94. width: '6%',
  95. cellTemplate: '<div>' +
  96. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.alarm.alarmSeverity}}</div>' +
  97. '</div>'
  98. }, {
  99. name: 'createTime',
  100. displayName: '告警时间',
  101. width: '11%',
  102. cellTemplate: '<div>' +
  103. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{row.entity.alarm.alarmActiveTime}}</div>' +
  104. '</div>'
  105. // },
  106. // {
  107. // name: '生成事件',
  108. // width: 80,
  109. // cellTemplate: '<div class="links cl-effect-1">' +
  110. // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="新建事件" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
  111. // '</div>'
  112. },
  113. {
  114. name: '操作',
  115. enableSorting: false,
  116. enableFiltering: false,
  117. width: 295,
  118. cellTemplate: '<wechatoperator item="row.entity" colobject="col">'
  119. // '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  120. // // '<a ng-click="edit()" ng-show="{{handle}}" tooltip="生成事件" tooltip-placement="left"><i class="icon iconfont icon-bianji bianjifont"></i></a>' +
  121. // '<a ng-click="edit()" ng-if="handle" class="bianjifont">建单</a>' + '<a ng-click="notAccept ()" class="bianjifont">不受理</a>' + '<a ng-click="being ()" class="bianjifont">暂不处理</a>' +
  122. // // '<a ng-click="look()" ng-show="{{!handle}}" tooltip="查看" tooltip-placement="right"><i class="ti-eye"></i></a>' +
  123. // '</div>'
  124. }
  125. ];
  126. // console.log(row);
  127. $scope.wtwt = function(row) {
  128. console.log(row)
  129. }
  130. $scope.value = 10;
  131. $scope.decrement = function(row) {
  132. $scope.value = $scope.value - 1;
  133. };
  134. // $scope.record = function() {
  135. // api_text.record($rootScope.takes).then(function(data){
  136. // if(data.errno==0){
  137. // $scope.busy=false;
  138. // }
  139. // })
  140. // };
  141. $scope.gridOptions.onRegisterApi = function(gridApi) {
  142. // console.log(row);
  143. $scope.gridApi = gridApi;
  144. // var index = 0;
  145. // var oldheader = {};
  146. // gridApi.grid.sortColumn = function(gridApi) {
  147. // if (oldheader.field) {
  148. // if (oldheader.field == gridApi.field) {
  149. // // index = 0;
  150. // } else {
  151. // index = 0;
  152. // }
  153. // }
  154. // index++;
  155. // oldheader = gridApi;
  156. // var fildata = $scope.memoryfilterData;
  157. // if (index % 3 == 0) {
  158. // delete $scope.memoryfilterData.incident;
  159. // fildata = $scope.memoryfilterData;
  160. // } else if (index % 3 == 1) {
  161. // angular.extend(fildata, { 'incident': { "sort": gridApi.field } });
  162. // } else if (index % 3 == 2) {
  163. // angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
  164. // }
  165. // $scope.refreshData('expand-right', fildata);
  166. // }
  167. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  168. var filtersData = $scope.memoryfilterData;
  169. filtersData.idx = newPage - 1;
  170. filtersData.sum = pageSize;
  171. $scope.refreshData('expand-right', filtersData);
  172. // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
  173. });
  174. $scope.selected = {
  175. items: []
  176. }
  177. };
  178. $scope.memoryfilterData = defaultFilterData = {
  179. // "assignee":$rootScope.user.id,
  180. // "candidateGroups":$rootScope.user.group[0].id,
  181. "idx": 0,
  182. "sum": mun,
  183. 'alarmIncident': {
  184. "state": ''
  185. }
  186. };
  187. $scope.selectRowFunction = function(data) {
  188. console.log(data)
  189. var formdata = {
  190. // 'model': {
  191. // 'incident': {
  192. // 'requester': data.requester,
  193. // 'area': data.area,
  194. // 'place': data.place,
  195. // 'houseNumber': data.address,
  196. // 'contacts': data.contacts,
  197. // 'contactsInformation': data.contactsInformation,
  198. // // 'category': data.wxIncidentClassifyDTO.category,
  199. // 'description': data.incidentDescription,
  200. // 'source': { 'id': 4 },
  201. // 'sourceType': data.sourceType,
  202. // 'fileUrl': data.fileUrl
  203. // },
  204. // 'networkInformation': data.requester,
  205. // 'flow': data.id
  206. // }
  207. 'alarmIncident': data
  208. }
  209. console.log(formdata)
  210. // if (formdata.alarmIncident.state == '未建单') {
  211. // formdata.alarmIncident.state = 0;
  212. // }
  213. delete(formdata.alarmIncident.item);
  214. console.log(formdata);
  215. // if (data.requester.requesterTypeDTO && data.requester.requesterTypeDTO.id == 2) {
  216. // angular.extend(formdata.model.incident, { 'priority': { 'id': 2 } });
  217. // }
  218. if (formdata.alarmIncident.alarm.alarmExtension) {
  219. formdata.alarmIncident.alarm.alarmExtension = formdata.alarmIncident.alarm.alarmExtension.replace('{', "");
  220. formdata.alarmIncident.alarm.alarmExtension = formdata.alarmIncident.alarm.alarmExtension.replace('}', "");
  221. // formdata.alarmIncident.alarm.alarmExtension = formdata.alarmIncident.alarm.alarmExtension.replace(/,/g, '\n');
  222. }
  223. console.log(formdata);
  224. $state.go('app.incident.chart', { 'model': JSON.stringify(formdata) });
  225. };
  226. $scope.lookFunction = function(data) {
  227. var modelfile = { model: { incident: data } };
  228. // $state.go('app.incident.detail', { formKey: 'incident_back', pdKey: 'incident', dataId: data.id, taskId: data.taskId, processInstanceId: data.processInstanceId });
  229. if (data.state == "未转换") {
  230. angular.extend(modelfile.model.incident, { status: 1 })
  231. } else {
  232. angular.extend(modelfile.model.incident, { status: 0 })
  233. }
  234. $state.go('app.desk.form_editor', { formKey: 'desk_detail', service: 'api_user_data', model: JSON.stringify(modelfile) });
  235. };
  236. // $scope.followFunction = function(data){
  237. // //console.log('data='+JSON.stringify(data));
  238. // $state.go('app.detail', { formKey:'statusform', pdKey:'incident', dataId: data.id,processInstanceId: data.processInstanceId});
  239. // };
  240. $scope.onDblClick = function(row) {
  241. console.log(row)
  242. if (row.entity.alarm.alarmExtension) {
  243. row.entity.alarm.alarmExtension = row.entity.alarm.alarmExtension.replace('{', "");
  244. row.entity.alarm.alarmExtension = row.entity.alarm.alarmExtension.replace('}', "");
  245. row.entity.alarm.alarmExtension = row.entity.alarm.alarmExtension.replace(/,/g, '\n');
  246. }
  247. event.stopPropagation();
  248. var modelfile = { model: row.entity };
  249. // if (row.entity.state == "未转换") {
  250. // angular.extend(modelfile.model.incident, { status: 1 })
  251. // } else {
  252. // angular.extend(modelfile.model.incident, { status: 0 })
  253. // }
  254. console.log(modelfile)
  255. $state.go('app.desk.form_editor', { formKey: 'desk_emergency', service: 'api_user_data', model: JSON.stringify(modelfile) });
  256. };
  257. var defaultFilterData = {
  258. // "assignee":$rootScope.user.id,
  259. // "candidateGroups":$rootScope.user.group[0].id,
  260. "idx": 0,
  261. "sum": 15,
  262. alarmIncident: {
  263. state: '未处理',
  264. }
  265. };
  266. // if(angular.isDefined($rootScope.search)&&angular.isDefined($rootScope.search.incident)){
  267. // defaultFilterData['searchType']=$rootScope.search.incident;
  268. // $scope.searchTypes=$rootScope.search.incident;
  269. // }
  270. // if($rootScope['cmdbs']!='incident'){$rootScope.idx=1}
  271. // if(angular.isDefined($rootScope.idx)&&$rootScope.cmdbs!="false"){
  272. // $rootScope['cmdbs']='incident';
  273. // defaultFilterData.idx=$rootScope.idx-1;
  274. // }else{$rootScope.cmdbs="";}
  275. $scope.ldloading = {};
  276. // $scope.Change= function(upTypes){
  277. // if(angular.isDefined(upTypes)&&upTypes=='upincident'){
  278. // $state.go('app.problem.incident',{});
  279. // }
  280. // else if(angular.isDefined(upTypes)&&upTypes=='upchange'){
  281. // $state.go('app.change.incident',{});
  282. // }
  283. // }
  284. // $scope.submit = function(searchType) {
  285. // api_apply.wxIncidentReject(1, { "rejectRemark": "不受理" }).then(function(data) {
  286. // if (data && data.status == 200) {
  287. // SweetAlert.swal({
  288. // title: "提交成功",
  289. // text: '不受理提交成功',
  290. // type: "success",
  291. // }, function() {
  292. // $scope.reload();
  293. // });
  294. // } else {
  295. // SweetAlert.swal({
  296. // title: "提交失败",
  297. // text: '不受理提交失败',
  298. // type: "error"
  299. // });
  300. // }
  301. // });
  302. // }
  303. $scope.searchstate = '未处理';
  304. $scope.onChange = function(searchType) {
  305. console.log(searchType)
  306. $scope.searchstate = searchType;
  307. // defaultFilterData = $scope.memoryfilterData;
  308. // defaultFilterData['searchType'] = searchType;
  309. defaultFilterData.alarmIncident.state = searchType
  310. console.log(defaultFilterData)
  311. $scope.refreshData(defaultFilterData);
  312. }
  313. $scope.refreshData = function(style, filterData) {
  314. // $scope.ldloading[style.replace('-', '_')] = true;
  315. if (angular.isUndefined(filterData)) {
  316. filterData = defaultFilterData;
  317. }
  318. console.log($scope.searchstate);
  319. filterData.alarmIncident.state = $scope.searchstate
  320. console.log(filterData);
  321. $scope.myData = [];
  322. $scope.gridOptions['sum'] = filterData.sum;
  323. api_bpm_data.fetchDataList("alarmIncident", filterData, 'alarmIncident').then(function(data) {
  324. console.log(data)
  325. var myData6 = Restangular.stripRestangular(data);
  326. $scope.gridOptions['totalItems'] = myData6.totalNum;
  327. $scope.myData = myData6.list;
  328. for (var i = 0; i < $scope.myData.length; i++) {
  329. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  330. }
  331. // $scope.handle = false;
  332. // $scope.notBeing = false;
  333. // for (var i = 0; i < $scope.myData.length; i++) {
  334. // $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum;
  335. // // $scope.TIME = $scope.myData[i].alarm['alarmActiveTime'];
  336. // // $scope.myData[i].alarm.alarmActiveTime = moment($scope.TIME).format("YYYY-MM-DD HH:mm:ss");
  337. // console.log($scope.myData[i]['state'])
  338. // if ($scope.myData[i]['state'] == '未处理') {
  339. // $scope.handle = true;
  340. // $scope.notBeing = true;
  341. // }
  342. // else {
  343. // $scope.handle = false;
  344. // }
  345. // if ($scope.myData[i]['state'] == '暂不处理') {
  346. // $scope.notBeing = false;
  347. // $scope.handle = true;
  348. // }
  349. // }
  350. // $scope.ldloading[style.replace('-', '_')] = false;
  351. }, function() {
  352. // $scope.ldloading[style.replace('-', '_')] = false;
  353. });
  354. };
  355. $scope.refreshData('expand-right', defaultFilterData);
  356. }
  357. ]);
  358. app.controller('WechatOperCtrl', ['$rootScope', '$http', '$scope', '$modal', 'SweetAlert', '$state', 'api_bpm_data', function($rootScope, $http, $scope, $modal, SweetAlert, $state, api_bpm_data) {
  359. $scope.handle = false;
  360. console.log($scope.item);
  361. console.log($rootScope.user)
  362. if ($scope.item.state == '未处理') {
  363. $scope.handle = true;
  364. $scope.notBeing = true;
  365. } else {
  366. $scope.handle = false;
  367. }
  368. if ($scope.item.state == '暂不处理') {
  369. $scope.notBeing = false;
  370. $scope.handle = true;
  371. }
  372. if ($scope.item.alarm.alarmStatus == '恢复') {
  373. $scope.notBeing = false;
  374. $scope.handle = false;
  375. }
  376. // console.log($scope.notBeing);
  377. // 处理 --wt
  378. $scope.edit = function() {
  379. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  380. // $scope.doEdit($scope.item.id);
  381. // console.log($scope.item)
  382. }
  383. // 不处理 --wt
  384. $scope.notAccept = function() {
  385. console.log($scope.item);
  386. var modalInstance = $modal.open({
  387. templateUrl: 'assets/views/desk/emergencyReason.html',
  388. controller: function($scope, $modalInstance, SweetAlert, item, $scope1, style, filterData) {
  389. $scope.ok = function() {
  390. console.log($scope1.colobject.grid.appScope);
  391. if ($scope.rejectRemark) {
  392. item.rejectRemark = $scope.rejectRemark;
  393. item.oprator = $rootScope.user.name;
  394. delete(item.item);
  395. console.log(item);
  396. item.state = "不受理";
  397. item = { alarmIncident: item };
  398. api_bpm_data.notAcceptData(item).then(function(data) {
  399. console.log(data)
  400. })
  401. console.log(item)
  402. SweetAlert.swal({
  403. title: "提交成功!",
  404. confirmButtonColor: "#007AFF"
  405. });
  406. $modalInstance.dismiss('cancel');
  407. $scope1.colobject.grid.appScope.refreshData(style, filterData);
  408. } else {
  409. SweetAlert.swal({
  410. title: "不受理原因为空!",
  411. confirmButtonColor: "#007AFF"
  412. });
  413. }
  414. // $state.go('app.desk.emergency', {});
  415. };
  416. $scope.cancel = function() {
  417. $modalInstance.dismiss('cancel');
  418. };
  419. },
  420. size: 'sm',
  421. resolve: {
  422. item: function() {
  423. return $scope.item;
  424. },
  425. $scope1: function() {
  426. return $scope;
  427. },
  428. style: function() {
  429. return $rootScope.stylewt;
  430. },
  431. filterData: function() {
  432. return $rootScope.filterDatawt;
  433. }
  434. }
  435. });
  436. // $scope.colobject.grid.appScope.lookFunction($scope.item);
  437. // $scope.doEdit($scope.item.id);
  438. };
  439. // 暂不处理 --wt
  440. $scope.being = function() {
  441. console.log($scope.item);
  442. console.log($scope.colobject.grid.appScope)
  443. $scope.item.oprator = $rootScope.user.name;
  444. $scope.item.state = '暂不处理'
  445. delete($scope.item.item);
  446. console.log($scope.item)
  447. $scope.item = { alarmIncident: $scope.item };
  448. api_bpm_data.notAcceptData($scope.item).then(function(data) {
  449. console.log(data)
  450. if (data.status == 200) {
  451. $scope.notBeing = false;
  452. $scope.colobject.grid.appScope.refreshData($rootScope.stylewt, $rootScope.filterDatawt);
  453. }
  454. })
  455. }
  456. }]);
  457. app.directive('wechatoperator', function() {
  458. return {
  459. restrict: 'E',
  460. scope: {
  461. item: '=',
  462. colobject: '='
  463. },
  464. controller: 'WechatOperCtrl',
  465. template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  466. // '<a ng-click="edit()" ng-show="{{handle}}" tooltip="生成事件" tooltip-placement="left"><i class="icon iconfont icon-bianji bianjifont"></i></a>' +
  467. '<a ng-click="edit()" ng-show="{{handle}}" class="bianjifont">建单</a>' + '<a ng-click="notAccept ()" ng-show="{{handle}}" class="bianjifont">不受理</a>' + '<a ng-click="being ()" ng-show="{{notBeing}}" class="bianjifont">暂不处理</a>' +
  468. // '<a ng-click="look()" ng-show="{{!handle}}" tooltip="查看" tooltip-placement="right"><i class="ti-eye"></i></a>' +
  469. '</div>'
  470. };
  471. });