incidentCtrl.js 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305
  1. 'use strict';
  2. app.controller('incidentListCtrl', ["$scope", "$http", "i18nService", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_text", "api_bpm_data", "api_user_data", "api_configure_data", '$parse', "$injector", "$aside", 'toaster', "api_configure_form", "api_cmdb", 'api_bpm', 'api_wechatfile','api_search_area','api_bpm_schedule','api_statistic','api_flow', function ($scope, $http, i18nService, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_text, api_bpm_data, api_user_data, api_configure_data, $parse, $injector, $aside, toaster, api_configure_form, api_cmdb, api_bpm, api_wechatfile,api_search_area,api_bpm_schedule,api_statistic,api_flow) {
  3. //保存报修主体
  4. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  5. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  6. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  7. $rootScope.isFuwutai = JSON.parse(localStorage.getItem("isFuwutai")) ? true : false;
  8. // ----------------分割线 start-----------------
  9. console.log($state)
  10. // 显示隐藏
  11. $scope.isDeployment = false;
  12. $scope.deploymentHandler = function(){
  13. $scope.isDeployment = !$scope.isDeployment;
  14. console.log($('#filterSearch .incidentsearch:gt(7)'));
  15. if($scope.isDeployment){
  16. $('#filterSearch .incidentsearch:gt(7)').css('display', 'inline-block');
  17. }else{
  18. $('#filterSearch .incidentsearch:gt(7)').css('display', 'none');
  19. }
  20. }
  21. // -----------------分割线 end----------------
  22. // 是否逾期seimin
  23. $scope.selectType = [
  24. { id: '2', name: '是' },
  25. { id: '0', name: '否' }
  26. ];
  27. // /是否逾期
  28. $scope.langs = i18nService.getAllLangs();
  29. $scope.lang = 'zh-cn';
  30. i18nService.setCurrentLang($scope.lang);
  31. $scope.myData = [];
  32. var loginUser = $rootScope.user;
  33. $scope.allFlag = false;//全部事件
  34. $scope.daochu = false;//导出
  35. for (var i = 0; i < loginUser.menu.length; i++) {
  36. if (loginUser.menu[i].link == "shijianliebiao_all") {
  37. $scope.allFlag = true
  38. }
  39. if (loginUser.menu[i].link == "shijianliebiao_daochu") {
  40. $scope.daochu = true
  41. }
  42. }
  43. var loginuserGroup = "";
  44. for (var i = 0; i < $rootScope.user.group.length; i++) {
  45. if (i == 0) {
  46. loginuserGroup = $rootScope.user.group[i].id;
  47. } else {
  48. loginuserGroup = loginuserGroup + "," + $rootScope.user.group[i].id;
  49. }
  50. }
  51. // 处理人,受理人,转派人
  52. var pdKey = $state.current.pdKey;
  53. $scope.gridOptions = {};
  54. $scope.gridOptions.data = 'myData';
  55. $scope.gridOptions.rowHeight = 54;
  56. $scope.gridOptions.enableColumnResizing = true;
  57. $scope.gridOptions.enableFiltering = false;
  58. $scope.gridOptions.enableGridMenu = true;
  59. $scope.gridOptions.enableSelectAll = true;
  60. $scope.gridOptions.enableRowSelection = true;
  61. $scope.gridOptions.showGridFooter = true;
  62. $scope.gridOptions.showColumnFooter = false;
  63. $scope.gridOptions.fastWatch = true;
  64. $scope.gridOptions.enableSorting = true;
  65. $scope.gridOptions.useExternalSorting = true;
  66. $scope.gridOptions.useExternalFiltering = false;
  67. $scope.gridOptions.useExternalPagination = true;
  68. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  69. $scope.gridOptions.paginationPageSize = 10;
  70. $scope.gridOptions.multiSelect = true;
  71. var mun = $scope.gridOptions.paginationPageSize;
  72. $scope.gridOptions.rowTemplate = "<div ng-click=\"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>";
  73. $scope.gridOptions.rowIdentity = function (row) {
  74. return row.id;
  75. };
  76. $scope.gridOptions.getRowIdentity = function (row) {
  77. return row.id;
  78. };
  79. $scope.transferColor = function (item) {
  80. var color = "icon iconfont icon-zhengchang greenfont";
  81. if (item.colourInfo) {
  82. if (item.colourInfo.id == 1583) {
  83. color = "icon iconfont icon-yiyuqi redfont";
  84. } else if (item.colourInfo.id == 1584) {
  85. color = "iconfont icon-yuqixinxiu orangefont";
  86. }
  87. }
  88. return color;
  89. }
  90. $scope.transfertip = function (item) {
  91. var tip = "正常";
  92. if (item.colourInfo) {
  93. if (item.colourInfo.id == 1583) {
  94. tip = "已逾期";
  95. } else if (item.colourInfo.id == 1584) {
  96. tip = "即将逾期";
  97. } else if (item.colourInfo.id == 1586) {
  98. tip = "正常";
  99. }
  100. }
  101. return tip;
  102. }
  103. $scope.transferstatus = function (item) {
  104. var statecolor = "#fc4c58";
  105. if (item.id == 2) { //待处理
  106. statecolor = "#fc4c58";
  107. } else if (item.id == 7) { //待审核
  108. statecolor = "#fcb44c";
  109. } else if (item.id == 3) { //请求重新指派
  110. statecolor = "#ebf902";
  111. } else if (item.id == 4) { //处理中
  112. statecolor = "#0aa5f5";
  113. } else if (item.id == 5) { //已解决
  114. statecolor = "#2edbb8";
  115. } else if (item.id == 6) { //已关闭
  116. statecolor = "#bbbbbb";
  117. }
  118. return statecolor;
  119. }
  120. if($scope.repairMain.valueconfig == 1){//报修人
  121. $scope.gridOptions.columnDefs = [
  122. {
  123. name: 'id',
  124. displayName: '',
  125. width: 35,
  126. cellTemplate: '<div>' +
  127. '<div class="ui-grid-cell-contents" tooltip={{grid.appScope.transfertip(row.entity)}} tooltip-placement="right"><i style="font-size: 18px !important;" class="{{grid.appScope.transferColor(row.entity)}}"></i></div></div>' +
  128. '</div>'
  129. },
  130. {
  131. name: 'item',
  132. displayName: '序号',
  133. width: 45,
  134. cellTemplate: '<div>' +
  135. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  136. '</div>'
  137. },
  138. {
  139. name: 'incidentsign',
  140. displayName: '事件单号',
  141. width: 120,
  142. cellTemplate: '<div>' +
  143. '<div class="ui-grid-cell-contents">{{row.entity.incidentsign}}</div>' +
  144. '</div>'
  145. },
  146. {
  147. name: 'requester.name',
  148. displayName: '报修人',
  149. width: '6%',
  150. minWidth: '90',
  151. enableSorting: false,
  152. cellTemplate: '<div>' +
  153. '<div class="ui-grid-cell-contents" >{{row.entity.requester.name}}</div>' +
  154. '</div>'
  155. },
  156. {
  157. name: 'requester.account',
  158. displayName: '学工号',
  159. width: '6%',
  160. minWidth: '90',
  161. enableSorting: false,
  162. cellTemplate: '<div>' +
  163. '<div class="ui-grid-cell-contents" >{{row.entity.requester.account}}</div>' +
  164. '</div>'
  165. },
  166. {
  167. name: 'contactsInformation',
  168. displayName: '联系电话',
  169. width: '105',
  170. cellTemplate: '<div>' +
  171. '<div class="ui-grid-cell-contents">{{row.entity.contactsInformation}}</div>' +
  172. '</div>'
  173. },
  174. {
  175. name: 'category',
  176. displayName: '故障现象',
  177. width: '10%',
  178. enableSorting: false,
  179. cellTemplate: '<div>' +
  180. '<div class="ui-grid-cell-contents">{{row.entity.category.category}}</div>' +
  181. '</div>'
  182. },
  183. {
  184. name: 'houseNumber',
  185. displayName: '区域地点',
  186. width: '14%',
  187. enableFiltering: false,
  188. cellTemplate: '<div><div class="ui-grid-cell-contents" ng-bind-html="grid.appScope.areaplace(row.entity)"></div></div>'
  189. },
  190. {
  191. name: 'acceptUser.name',
  192. displayName: '受理人',
  193. width: '7%',
  194. minWidth: '80',
  195. enableSorting: false,
  196. cellTemplate: '<div>' +
  197. '<div class="ui-grid-cell-contents" >{{row.entity.acceptUser.name}}</div>' +
  198. '</div>'
  199. },
  200. {
  201. name: 'acceptDate',
  202. displayName: '登记时间',
  203. width: '10%',
  204. minWidth: '140',
  205. enableFiltering: false,
  206. cellTemplate: '<div><div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.acceptDate)}}</div></div>'
  207. },
  208. {
  209. name: 'groupORHandlerUser',
  210. displayName: '处理人/组',
  211. width: '10%',
  212. enableFiltering: false,
  213. cellTemplate: '<div>' +
  214. '<div class="ui-grid-cell-contents">' +
  215. '{{row.entity.groupORHandlerUser}}</div>' +
  216. '</div>'
  217. },
  218. {
  219. name: 'state.name',
  220. displayName: '状态',
  221. width: '7%',
  222. minWidth: '70',
  223. enableSorting: false,
  224. cellTemplate: '<div>' +
  225. '<div class="ui-grid-cell-contents" >{{row.entity.state.name}}</div>' +
  226. '</div>'
  227. },
  228. {
  229. name: '操作',
  230. enableSorting: false,
  231. width: 500,
  232. cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
  233. enableFiltering: false
  234. },
  235. ];
  236. if($scope.wxIncidentWithCmdb==1){
  237. let index = $scope.gridOptions.columnDefs.findIndex(v=>v.name == 'contactsInformation');
  238. $scope.gridOptions.columnDefs.splice(index,0,{
  239. name: 'assetId',
  240. displayName: '资产',
  241. width: 120
  242. },)
  243. }
  244. }else if($scope.repairMain.valueconfig == 2){//报修科室
  245. $scope.gridOptions.columnDefs = [
  246. {
  247. name: 'id',
  248. displayName: '',
  249. width: 35,
  250. cellTemplate: '<div style="width: 100%;">' +
  251. '<div class="ui-grid-cell-contents" tooltip={{grid.appScope.transfertip(row.entity)}} tooltip-placement="right"><i style="font-size: 18px !important;" class="{{grid.appScope.transferColor(row.entity)}}"></i></div></div>' +
  252. '</div>'
  253. },
  254. {
  255. name: 'row1',
  256. displayName: '序号',
  257. width: 45,
  258. cellTemplate: '<div style="width: 100%;">' +
  259. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  260. '</div>'
  261. },
  262. {
  263. name: 'row2',
  264. displayName: '单号|报修科室',
  265. width: 150,
  266. cellTemplate: '<div style="width: 100%;">' +
  267. '<div class="ui-grid-cell-contents">{{row.entity.incidentsign || "无"}}<br>{{row.entity.department ? row.entity.department.dept : "无"}}</div>' +
  268. '</div>'
  269. },
  270. {
  271. name: 'row3',
  272. displayName: '报修人|来电电话',
  273. width: 150,
  274. cellTemplate: '<div style="width: 100%;">' +
  275. '<div class="ui-grid-cell-contents">{{row.entity.requester ? row.entity.requester.name : "无"}}<br>{{row.entity.incomingPhone || "无"}}<a ng-click="grid.appScope.play(row.entity)" ng-if="row.entity.callID" tooltip="播放录音" tooltip-placement="left"><i class="ti-microphone"></i></a></div>' +
  276. '</div>'
  277. },
  278. {
  279. name: 'row5',
  280. displayName: '故障现象|区域地点',
  281. width: 350,
  282. cellTemplate: '<div style="width: 100%;">' +
  283. '<div class="ui-grid-cell-contents"><span title="{{row.entity.description}}">{{row.entity.description}}</span><br><span ng-bind-html="grid.appScope.areaplace(row.entity)"></span></div>' +
  284. '</div>'
  285. },
  286. {
  287. name: 'row6',
  288. displayName: '受理人|处理人/组',
  289. width: 150,
  290. cellTemplate: '<div style="width: 100%;">' +
  291. '<div class="ui-grid-cell-contents">{{row.entity.acceptUser ? row.entity.acceptUser.name : "无"}}<br>{{row.entity.groupORHandlerUser || "无"}}</div>' +
  292. '</div>'
  293. },
  294. {
  295. name: 'row7',
  296. displayName: '登记时间|接单时间',
  297. width: 150,
  298. cellTemplate: '<div style="width: 100%;">' +
  299. '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.acceptDate)}}<br>{{grid.appScope.transferTime(row.entity.responseHandleTime)}}</div>' +
  300. '</div>'
  301. },
  302. {
  303. name: 'row9',
  304. displayName: '状态|解决时间',
  305. width: 150,
  306. cellTemplate: '<div style="width: 100%;">' +
  307. '<div class="ui-grid-cell-contents" ><span ng-switch="row.entity.state.value"><span ng-switch-when="pending" style="color:orange;">{{row.entity.state.name}}</span><span ng-switch-when="resolved" style="color:green;">{{row.entity.state.name}}</span><span ng-switch-when="handler" style="font-weight:bold;">{{row.entity.state.name}}</span><span ng-switch-default>{{row.entity.state.name}}</span></span><br>{{grid.appScope.transferTime(row.entity.handleTime)}}</div>' +
  308. '</div>'
  309. },
  310. {
  311. name: 'row10',
  312. displayName: '最近维修记录',
  313. width: 140,
  314. cellTemplate: '<div style="width: 100%;">' +
  315. '<div class="ui-grid-cell-contents" ng-bind-html="grid.appScope.transferHandlerLog(row.entity.handlerLogs)"></div>' +
  316. '</div>'
  317. },
  318. {
  319. name: '操作',
  320. enableSorting: false,
  321. width: 196,
  322. cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
  323. enableFiltering: false
  324. },
  325. ];
  326. }
  327. $scope.transferTime = function (time) {
  328. if(time){
  329. return moment(time).format('YYYY-MM-DD HH:mm');
  330. }else{
  331. return '无';
  332. }
  333. }
  334. $scope.transferHandlerLog = function (handlerLogs) {
  335. handlerLogs = angular.copy(handlerLogs);
  336. handlerLogs = handlerLogs.reverse();
  337. if(handlerLogs.length){
  338. if(handlerLogs[0].repairType && handlerLogs[0].expectedDate){
  339. return handlerLogs[0].repairType.name+"<br>"+ moment(handlerLogs[0].expectedDate).format('MM月DD日前完成');
  340. }else{
  341. return '无';
  342. }
  343. }else{
  344. return '无';
  345. }
  346. }
  347. $scope.endOpen = function ($event) {
  348. $event.preventDefault();
  349. $event.stopPropagation();
  350. $scope.startOpened = false;
  351. $scope.endOpened = !$scope.endOpened;
  352. };
  353. $scope.startOpen = function ($event) {
  354. $event.preventDefault();
  355. $event.stopPropagation();
  356. $scope.endOpened = false;
  357. $scope.startOpened = !$scope.startOpened;
  358. };
  359. $scope.othcode = {};
  360. $scope.searchkeys = {deleted:false};
  361. // 是否选择已删除
  362. $scope.selectDeleted = function(e){
  363. console.log($scope.searchkeys.deleteFlag);
  364. $scope.chiceIncident($scope.searchkeys,$scope.othcode.state);
  365. }
  366. $scope.my_data = [];
  367. function convertListToTree(data, treeMap) {
  368. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  369. var root = null; //Initially set our loop to null
  370. var parentNode = null;
  371. //loop over data
  372. for (var i = 0; i < data.length; i++) {
  373. var datum = data[i];
  374. //each node will have children, so let's give it a "children" poperty
  375. datum.children = [];
  376. //add an entry for this node to the map so that any future children can
  377. //lookup the parent
  378. idToNodeMap[datum.id] = datum;
  379. //Does this node have a parent?
  380. if (typeof datum.parent === "undefined" || datum.parent == null) {
  381. //Doesn't look like it, so this node is the root of the tree
  382. root = datum;
  383. treeMap[datum.id] = root;
  384. } else {
  385. //This node has a parent, so let's look it up using the id
  386. parentNode = idToNodeMap[datum.parent.id];
  387. //We don't need this property, so let's delete it.
  388. delete datum.parent;
  389. //Let's add the current node as a child of the parent node.
  390. parentNode.children.push(datum);
  391. }
  392. }
  393. return root;
  394. }
  395. function convertParentToChildList(data) {
  396. var treeMap = {};
  397. var list = [];
  398. convertListToTree(data, treeMap);
  399. angular.forEach(treeMap, function (item) {
  400. list.push(item);
  401. });
  402. return list;
  403. }
  404. $scope.my_tree = {};
  405. $scope.select_treedata = [];
  406. // 报修科室
  407. $scope.getDept = function (key) {
  408. var postData = {
  409. "idx": 0,
  410. "sum": 10
  411. }
  412. if (key) {
  413. postData.department = { dept: key }
  414. }
  415. api_user_data.fetchDataList('department', postData).then(function (response) {
  416. if (response) {
  417. if (response.status = 200) {
  418. $scope.department = response.list;
  419. }
  420. }
  421. })
  422. }
  423. $scope.getDept();
  424. //树形图
  425. // 将故障现象搜索结果返回的数据整理成children模式
  426. function transform(nodes) {
  427. var treeConverter = {
  428. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  429. attributeName: 'id', //节点唯一标识符
  430. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  431. transform: function (node) { //转化递归函数,参数:一个待插入节点
  432. if (node.parent != null) { //该节点有父节点
  433. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  434. if (this.needFind) {
  435. for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
  436. if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
  437. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  438. }
  439. }
  440. }
  441. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  442. // delete node.parent; //删除该节点的parent属性,如果有的话
  443. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  444. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  445. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  446. } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
  447. // delete node.parent; //删除该节点的parent属性,如果有的话
  448. if (this.result == null) { //根节点不存在
  449. node.children = []; //给该节点增加children:[]属性
  450. return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  451. } else {
  452. node.children = [];
  453. // 顶级去重
  454. for (var i = 0; i < this.result.children.length; i++) {
  455. if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
  456. return this.result.children[i];
  457. }
  458. }
  459. this.result.children.push(node)
  460. return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  461. }
  462. }
  463. },
  464. getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  465. var _node = {};
  466. _node.children = [];
  467. this.result = _node; //重置根节点
  468. this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
  469. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  470. nodes.forEach(item => { //循环调用转化方法
  471. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  472. this.transform(item);
  473. })
  474. return this.result; //返回根节点
  475. }
  476. }
  477. var result = treeConverter.getWhole(nodes); //调用
  478. return result;
  479. }
  480. $scope.my_tree = {};
  481. $rootScope.bala1 = $scope.try_async_load = function (s, fn) {
  482. if (s) {
  483. var filterKeyword = s.filterKeyword;
  484. }
  485. var postData = {
  486. "idx": 0,
  487. "sum": 1000,
  488. "incidentcategory": {},
  489. }
  490. if (filterKeyword) {
  491. postData.incidentcategory = { selectType: "pinyin_qs", category: filterKeyword }
  492. }
  493. // 当前所属院区或责任科室
  494. if($rootScope.user.duty){
  495. postData.incidentcategory.duty = $rootScope.user.duty.id;
  496. }else if($rootScope.user.branch){
  497. postData.incidentcategory.branch = $rootScope.user.branch.id;
  498. }
  499. $scope.my_data = [];
  500. $scope.doing_async = true;
  501. api_bpm_data.fetchDataList('incidentcategory', postData).then(function (response) {
  502. if (response.status == 200) {
  503. var data = response.list;
  504. if (filterKeyword) {
  505. data.forEach(e => {
  506. e.isExpanded = true;
  507. })
  508. var li = transform(data).children;
  509. console.log(li)
  510. fn(li)
  511. return;
  512. } else {
  513. var objects = [];
  514. for (var i = 0; i < data.length; i++) {
  515. var object = {};
  516. object.id = data[i].id;
  517. object.parent = data[i].parent;
  518. object.category = data[i].category;
  519. object.isExpanded = true;
  520. objects.push(object);
  521. }
  522. $scope.my_data = convertParentToChildList(objects);
  523. $scope.select_treedata = angular.copy($scope.my_data);
  524. }
  525. if ($scope.my_data.length > 0) {
  526. $scope.doing_async = false;
  527. }
  528. } else {
  529. SweetAlert.swal({
  530. title: "系统错误!",
  531. text: "请刷新重试!",
  532. type: "error"
  533. });
  534. }
  535. });
  536. };
  537. $scope.my_data = [];
  538. function convertListToTree(data, treeMap) {
  539. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  540. var root = null; //Initially set our loop to null
  541. var parentNode = null;
  542. //loop over data
  543. for (var i = 0; i < data.length; i++) {
  544. var datum = data[i];
  545. //each node will have children, so let's give it a "children" poperty
  546. datum.children = [];
  547. //add an entry for this node to the map so that any future children can
  548. //lookup the parent
  549. idToNodeMap[datum.id] = datum;
  550. //Does this node have a parent?
  551. if (typeof datum.parent === "undefined" || datum.parent == null) {
  552. //Doesn't look like it, so this node is the root of the tree
  553. root = datum;
  554. treeMap[datum.id] = root;
  555. } else {
  556. //This node has a parent, so let's look it up using the id
  557. parentNode = idToNodeMap[datum.parent.id];
  558. //We don't need this property, so let's delete it.
  559. delete datum.parent;
  560. //Let's add the current node as a child of the parent node.
  561. parentNode.children.push(datum);
  562. }
  563. }
  564. return root;
  565. }
  566. function convertParentToChildList(data) {
  567. var treeMap = {};
  568. var list = [];
  569. convertListToTree(data, treeMap);
  570. angular.forEach(treeMap, function (item) {
  571. list.push(item);
  572. });
  573. return list;
  574. }
  575. $scope.try_async_load();
  576. // 故障现象
  577. $scope.onFilterCallback = function (item) {
  578. console.log(item);
  579. if (item.item) {
  580. $scope.searchkeys.levelCategory = item = undefined;
  581. } else {
  582. $scope.searchkeys.levelCategory = item;
  583. }
  584. }
  585. //状态
  586. $scope.state = [];
  587. api_wechatfile.getDictionary({
  588. "type": "list",
  589. "key": "incident_status"
  590. }).then(function (response) {
  591. if (response) {
  592. if (response.status = 200) {
  593. $scope.state = response;
  594. }
  595. }
  596. })
  597. $scope.clear = function () {
  598. $scope.searchkeys = {};
  599. $scope.othcode = {};
  600. $scope.try_async_load();
  601. $scope.refreshData('expand-right');
  602. $interval.cancel($scope.timer);
  603. $scope.timer = $interval(function () {
  604. $scope.jry_refresh()
  605. }, $rootScope.refreshTime);
  606. }
  607. // 刷新
  608. $scope.jry_refresh = function () {
  609. var fildata = defaultFilterData;
  610. if (fildata.incident && fildata.incident.category) {
  611. delete fildata.incident.category
  612. }
  613. fildata.idx = $scope.jry_idx;
  614. fildata.sum = $scope.jry_sum;
  615. $scope.refreshData2('expand-right', fildata);
  616. console.log($scope.cifilter_classic);
  617. }
  618. // 搜索
  619. $scope.chiceIncident = function (item, stateid) {
  620. if (stateid && stateid.id) {
  621. item.statusId = stateid.id;
  622. } else {
  623. item.statusId = undefined;
  624. }
  625. console.log(item)
  626. var fildata = defaultFilterData;
  627. if (!fildata.incident) {
  628. fildata['incident'] = {};
  629. }
  630. if (item.acceptDate) {
  631. item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD 00:00:00');
  632. }
  633. if (item.acceptDateEnd) {
  634. item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD 23:59:59')
  635. }
  636. var transitiondata = angular.copy(item);
  637. angular.extend(fildata.incident, transitiondata)
  638. $scope.memoryfilterData = fildata;
  639. // seimin
  640. if($scope.searchstate === 'all_del'){
  641. fildata.searchType = 'all';
  642. }else{
  643. fildata.searchType = $scope.searchstate;
  644. }
  645. console.log(fildata,78777);
  646. if(fildata.searchType === 'all'){
  647. if(fildata.incident&&fildata.incident.selectType){
  648. fildata.incident.selectType = fildata.incident.selectType.id;
  649. }
  650. }else{
  651. if(fildata.incident&&fildata.incident.selectType){
  652. delete fildata.incident.selectType;
  653. }
  654. }
  655. // /seimin
  656. $scope.refreshData('expand-right', fildata);
  657. $interval.cancel($scope.timer);
  658. $scope.timer = $interval(function () {
  659. $scope.jry_refresh()
  660. }, $rootScope.refreshTime);
  661. }
  662. //区域地点过滤
  663. api_user_data.fetchDataList('area', {
  664. "idx": 0,
  665. "sum": 1000
  666. }).then(function (response) {
  667. if (response) {
  668. if (response.status = 200) {
  669. $scope.outarea = response.list;
  670. }
  671. }
  672. })
  673. //报修人
  674. var getRequester = function () {
  675. api_user_data.fetchDataList('requester', {
  676. idx: 0,
  677. sum: 100
  678. }).then(function (data) {
  679. // console.log(data);
  680. $scope.requester = data.list
  681. });
  682. }
  683. getRequester();
  684. //受理人,处理人
  685. var getUser = function (fieldatas, it) {
  686. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  687. if (it == 1) {
  688. $scope.acceptUser = data.list;
  689. } else if (it == 2) {
  690. $scope.handlingPersonnelUser = data.list;
  691. }
  692. });
  693. }
  694. //受理人过滤
  695. $scope.onChangeacceptUser = function (key) {
  696. console.log(key)
  697. var filuser = {
  698. "idx": 0,
  699. "sum": 10,
  700. "user": {
  701. "name": key,
  702. 'selectType': "pinyin_qs"
  703. }
  704. }
  705. getUser(filuser, 1);
  706. }
  707. //处理人过滤
  708. $scope.onChangehandling = function (key) {
  709. var filuser = {
  710. "idx": 0,
  711. "sum": 10,
  712. "user": {
  713. "name": key,
  714. 'selectType': "pinyin_qs"
  715. }
  716. }
  717. getUser(filuser, 2);
  718. }
  719. //报修科室过滤
  720. $scope.onChangeDept = function (key) {
  721. $scope.getDept(key)
  722. }
  723. //地点区域过滤
  724. $scope.onChangearea = function (data) {
  725. delete $scope.searchkeys.place;
  726. if ($scope.memoryfilterData.incident) {
  727. delete $scope.memoryfilterData.incident.place;
  728. }
  729. var fildata = {
  730. "idx": 0,
  731. "sum": 1000,
  732. "place": {
  733. area: {
  734. id: data.area.id
  735. }
  736. }
  737. };
  738. api_user_data.fetchDataList('place', fildata).then(function (response) {
  739. if (response) {
  740. if (response.status = 200) {
  741. $scope.outplace = response.list;
  742. }
  743. }
  744. })
  745. };
  746. $scope.starttime = function (data) {
  747. return moment(new Date(data)).format('YYYY-MM-DD')
  748. }
  749. $scope.overtime = function (data) {
  750. return moment(new Date(data)).format('YYYY-MM-DD HH:mm')
  751. }
  752. $scope.areaplace = function (data) {
  753. var str = '';
  754. str += '<strong>' + data.branchName + '</strong>';
  755. str += (data.place ? (data.place.area ? data.place.area.area : '') : '');
  756. str += (data.place ? (data.place.place ? data.place.place : '') : '');
  757. str += (data.houseNumber ? data.houseNumber : '');
  758. return str || '无';
  759. }
  760. //录音
  761. $scope.play = function (data) {
  762. console.log(data.callID)
  763. var modalInstance = $modal.open({
  764. backdrop: "static",
  765. templateUrl: 'assets/views/incident/tpl/audio.html',
  766. controller: function ($rootScope, $scope, $modalInstance, $sce, $http, api_bpm_data) {
  767. // $rootScope.setbusy();
  768. $scope.datasurl = "";
  769. api_bpm_data.fetchDataList("callrecord", {idx: 0, sum: 1, callrecord: {callAccept: data.callID}}).then(function(data) {
  770. if(data.status == 200){
  771. data.list = data.list || [];
  772. if(data.list.length){
  773. $scope.audioUrl = $sce.trustAsResourceUrl(callIp+data.list[0].recordingFileName);
  774. }
  775. }
  776. });
  777. $scope.download = function (contentId, filename) {
  778. $http({
  779. url: "http://" + $scope.datasurl,
  780. method: 'GET',
  781. headers: {
  782. 'Content-type': 'application/octet-stream',
  783. },
  784. responseType: 'arraybuffer'
  785. }).success(function (data, status, headers, config) {
  786. var file = new Blob([data], {
  787. type: 'application/octet-stream'
  788. });
  789. //trick to download store a file having its URL
  790. var fileURL = URL.createObjectURL(file);
  791. var a = document.createElement('a');
  792. a.href = fileURL;
  793. a.target = '_blank';
  794. a.download = filename;
  795. document.body.appendChild(a);
  796. a.click();
  797. }).error(function (data, status, headers, config) {
  798. // console.log(data);
  799. });
  800. }
  801. $scope.cancel = function () {
  802. $modalInstance.dismiss('cancel');
  803. };
  804. $modalInstance.close();
  805. },
  806. });
  807. modalInstance.result.then(function (result) {}, function (reason) {});
  808. };
  809. //列表排序
  810. $scope.gridOptions.onRegisterApi = function (gridApi) {
  811. $scope.gridApi = gridApi;
  812. var index = 0;
  813. var oldheader = {};
  814. gridApi.grid.sortColumn = function (gridApi) {
  815. if (oldheader.field) {
  816. if (oldheader.field == gridApi.field) {
  817. } else {
  818. index = 0;
  819. }
  820. }
  821. index++;
  822. oldheader = gridApi;
  823. var fildata = $scope.memoryfilterData;
  824. if (index % 3 == 0) {
  825. delete $scope.memoryfilterData.incident;
  826. fildata = $scope.memoryfilterData;
  827. } else if (index % 3 == 1) {
  828. if (fildata.incident) {
  829. if (gridApi.field == "acceptDate") {
  830. angular.extend(fildata.incident, {
  831. "sort": gridApi.field
  832. });
  833. } else {
  834. angular.extend(fildata.incident, {
  835. "sort": gridApi.field + " desc , _incident.acceptDate"
  836. });
  837. }
  838. } else {
  839. if (gridApi.field == "acceptDate") {
  840. angular.extend(fildata, {
  841. 'incident': {
  842. "sort": gridApi.field
  843. }
  844. });
  845. } else {
  846. angular.extend(fildata, {
  847. 'incident': {
  848. "sort": gridApi.field + " desc , _incident.acceptDate"
  849. }
  850. });
  851. }
  852. }
  853. } else if (index % 3 == 2) {
  854. if (fildata.incident) {
  855. if (gridApi.field == "acceptDate") {
  856. angular.extend(fildata.incident, {
  857. "sort": gridApi.field,
  858. "order": "asc"
  859. });
  860. } else {
  861. angular.extend(fildata.incident, {
  862. "sort": gridApi.field + " asc , _incident.acceptDate"
  863. });
  864. }
  865. } else {
  866. if (gridApi.field == "acceptDate") {
  867. angular.extend(fildata, {
  868. 'incident': {
  869. "sort": gridApi.field,
  870. "order": "asc"
  871. }
  872. });
  873. } else {
  874. angular.extend(fildata.incident, {
  875. "sort": gridApi.field + " asc , _incident.acceptDate"
  876. });
  877. }
  878. }
  879. }
  880. $scope.refreshData('expand-right', fildata);
  881. }
  882. $scope.jry_idx = 0;
  883. $scope.jry_sum = 10;
  884. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  885. var filtersData = $scope.memoryfilterData;
  886. filtersData.idx = newPage - 1;
  887. $scope.jry_idx = newPage - 1;
  888. filtersData.sum = pageSize;
  889. $scope.jry_sum = pageSize;
  890. });
  891. $scope.Change = function (upTypes) {
  892. if (angular.isDefined($scope.selected.items)) {
  893. if (angular.isDefined(upTypes) && upTypes == 'upincident') {
  894. var data = {
  895. cancelUrl: 'app.incident.list',
  896. model: {
  897. problem: {
  898. title: $scope.selected.items.title,
  899. des: $scope.selected.items.description,
  900. proposePerson: $scope.selected.items.handlerUser,
  901. source: {
  902. id: 1,
  903. code: 1,
  904. name: ' 事件 '
  905. },
  906. incident: $scope.selected.items
  907. }
  908. }
  909. }
  910. $state.go('app.problem.incident', {
  911. pdKey: 'incident',
  912. dataId: $scope.selected.items.id,
  913. processInstanceId: $scope.selected.items.processInstanceId,
  914. 'model': JSON.stringify(data)
  915. });
  916. } else if (angular.isDefined(upTypes) && upTypes == 'upchange') {
  917. var data = {
  918. cancelUrl: 'app.incident.list',
  919. model: {
  920. change: {
  921. title: $scope.selected.items.title,
  922. description: $scope.selected.items.description,
  923. requestingPerson: $scope.selected.items.handlerUser,
  924. source: {
  925. id: 1,
  926. code: 1,
  927. name: ' 事件 '
  928. },
  929. incident: $scope.selected.items
  930. }
  931. }
  932. }
  933. // var data={cancelUrl:'app.incident.list'}
  934. $state.go('app.change.incident', {
  935. pdKey: 'incident',
  936. dataId: $scope.selected.items.id,
  937. processInstanceId: $scope.selected.items.processInstanceId,
  938. 'model': JSON.stringify(data)
  939. });
  940. }
  941. }
  942. }
  943. $scope.selected = {
  944. items: []
  945. }
  946. gridApi.core.on.filterChanged($scope, function () {
  947. var grid = this.grid;
  948. if ($rootScope.user.group) {
  949. var filtersData = {
  950. idx: 0,
  951. sum: mun
  952. };
  953. } else {
  954. var filtersData = {
  955. idx: 0,
  956. sum: mun
  957. };
  958. }
  959. angular.forEach(grid.columns, function (item) {
  960. if (item.enableFiltering) {
  961. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  962. filtersData = $scope.memoryfilterData
  963. if (angular.isUndefined(filtersData['incident'])) {
  964. filtersData['incident'] = {};
  965. }
  966. if (item.field == 'department.dept') {
  967. filtersData['incident']['department'] = {};
  968. filtersData.incident.department['department'] = item.filters[0].term;
  969. } else if (item.field == 'handlingPersonnelUser.name') {
  970. filtersData['incident']['handlingPersonnelUser'] = {};
  971. filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
  972. } else if (item.field == 'requester.account') {
  973. filtersData['incident']['requester'] = {};
  974. filtersData.incident.requester['account'] = item.filters[0].term;
  975. } else if (item.field == 'acceptUser.name') {
  976. filtersData['incident']['acceptUser'] = {};
  977. filtersData.incident.acceptUser['name'] = item.filters[0].term;
  978. } else {
  979. filtersData['incident'][item.field] = item.filters[0].term;
  980. }
  981. }
  982. }
  983. });
  984. filtersData.idx = 0;
  985. $scope.memoryfilterData = filtersData;
  986. $scope.refreshData('expand-right', filtersData);
  987. });
  988. };
  989. //编辑
  990. $scope.selectRowFunction = function (data) {
  991. $state.go('app.incident.editor', {
  992. taskId: data.taskId,
  993. processInstanceId: data.processInstanceId,
  994. dataId: data.id,
  995. });
  996. };
  997. //修改
  998. $scope.changeClick = function (data) {
  999. $state.go('app.incident.detail', {
  1000. formKey: 'incident_change',
  1001. pdKey: 'incident',
  1002. dataId: data.id,
  1003. taskId: data.taskId,
  1004. processInstanceId: data.processInstanceId
  1005. });
  1006. };
  1007. //回访
  1008. $scope.visit = function (data) {
  1009. $state.go('app.incident.detail', {
  1010. formKey: 'incident_visit',
  1011. pdKey: 'incident',
  1012. dataId: data.id,
  1013. taskId: data.taskId,
  1014. processInstanceId: data.processInstanceId
  1015. });
  1016. };
  1017. //导出
  1018. $scope.export = function () {
  1019. console.log($scope.memoryfilterData)
  1020. var filadata = angular.copy($scope.memoryfilterData);
  1021. filadata.sum = 10000;
  1022. console.log($scope.filadata)
  1023. $http({
  1024. url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
  1025. method: 'POST',
  1026. data: JSON.stringify(filadata),
  1027. headers: {
  1028. 'Accept': '*/*'
  1029. },
  1030. responseType: 'arraybuffer'
  1031. }).success(function (data, status, headers, config) {
  1032. var file = new Blob([data], {
  1033. type: 'application/vnd.ms-excel'
  1034. });
  1035. //trick to download store a file having its URL
  1036. var fileURL = URL.createObjectURL(file);
  1037. var a = document.createElement('a');
  1038. a.href = fileURL;
  1039. a.target = '_blank';
  1040. a.download = '事件列表.xls';
  1041. document.body.appendChild(a);
  1042. a.click();
  1043. }).error(function (data, status, headers, config) {
  1044. // $scope.ldloading.zoom_in = false;
  1045. console.log(data);
  1046. });
  1047. }
  1048. //接单
  1049. $scope.acceptTaskAction = function (model) {
  1050. var modalInstance = $modal.open({
  1051. templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
  1052. controller: function ($scope, $modalInstance, modelData, currentUserId, Alert) {
  1053. $scope.title = "提示";
  1054. $scope.connect = "确认接单?";
  1055. $scope.ok = function () {
  1056. console.log(model);
  1057. $rootScope.isMask = true;
  1058. api_flow.accept("receive", {incident: model}).then(function (response) {
  1059. $rootScope.isMask = false;
  1060. if (response.state == 200) {
  1061. Alert.swal({
  1062. title: "操作成功!",
  1063. confirmButtonColor: "#007AFF",
  1064. type: "success"
  1065. });
  1066. $modalInstance.close('success');
  1067. } else {
  1068. Alert.swal({
  1069. title: "操作失败",
  1070. text: "操作失败, 请稍后再试!",
  1071. type: "error"
  1072. });
  1073. }
  1074. });
  1075. }
  1076. $scope.cancel = function () {
  1077. $modalInstance.dismiss('cancel');
  1078. }
  1079. },
  1080. size: 'sm',
  1081. resolve: {
  1082. modelData: function () {
  1083. return model;
  1084. },
  1085. currentUserId: function () {
  1086. return loginUser.id;
  1087. },
  1088. Alert: function () {
  1089. return SweetAlert;
  1090. }
  1091. }
  1092. });
  1093. modalInstance.result.then(function (selectedItem) {
  1094. if (selectedItem == 'success') {
  1095. $scope.refreshData('expand-right', defaultFilterData);
  1096. }
  1097. });
  1098. }
  1099. // 指派弹窗
  1100. $scope.toAssign = function (model) {
  1101. console.log(model)
  1102. var modalInstance = $modal.open({
  1103. templateUrl: 'assets/views/incident/tpl/toAssign.tpl.html',
  1104. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  1105. console.log(model,loginUser);
  1106. //获取组下面的用户
  1107. $scope.getUsers = function(groupId){
  1108. $scope.user = [];
  1109. var postData = {};
  1110. if(groupId){
  1111. postData = {
  1112. "idx": 0,
  1113. "sum": 100,
  1114. user: {
  1115. groupdata:{id:groupId},
  1116. roledata: { rolecode: "first-line support" },
  1117. roledata2: { rolecode: "second-line support" },
  1118. selectType: "1",
  1119. selectDetails:1,
  1120. simple: true,
  1121. }
  1122. }
  1123. }else{
  1124. postData = {
  1125. "idx": 0,
  1126. "sum": 100,
  1127. user: {
  1128. roledata: { rolecode: "first-line support" },
  1129. roledata2: { rolecode: "second-line support" },
  1130. selectType: "1",
  1131. selectDetails:1,
  1132. simple: true,
  1133. }
  1134. }
  1135. }
  1136. api_user_data.fetchDataList('user', postData).then(function (data) {
  1137. $scope.user = data.list;
  1138. })
  1139. }
  1140. $scope.assign = {
  1141. branch:undefined,
  1142. duty:undefined,
  1143. user:undefined,
  1144. group:undefined,
  1145. isRadioUser: 0,
  1146. }
  1147. $scope.hospitalList = [];
  1148. $scope.dutyDeptList = [];
  1149. $scope.user = [];
  1150. $scope.group = [];
  1151. $scope.isShowRadioUser = false;
  1152. // 修改是否指派到人
  1153. $scope.changeRadioUser = function(){
  1154. $scope.assign.user = undefined;
  1155. }
  1156. // 获取院区
  1157. $scope.getHospitals = function(){
  1158. //跨科室转派
  1159. api_user_data.fetchDataList('branch', {
  1160. "idx": 0,
  1161. "sum": 100
  1162. }).then(function (data) {
  1163. if(data.status == 200){
  1164. $scope.hospitalList = data.list;
  1165. if($scope.assign.duty){
  1166. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $scope.assign.duty.branch);
  1167. }else{
  1168. if($rootScope.user.duty){
  1169. // 当前的所属责任科室
  1170. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  1171. $scope.assign.duty = $rootScope.user.duty;
  1172. $scope.changeDuty();
  1173. }else if($rootScope.user.branch){
  1174. // 当前的所属院区
  1175. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  1176. }
  1177. }
  1178. }else{
  1179. SweetAlert.swal({
  1180. title: "系统错误!",
  1181. text: "请刷新重试!",
  1182. type: "error"
  1183. });
  1184. }
  1185. })
  1186. }
  1187. $scope.getHospitals();
  1188. // 修改院区
  1189. $scope.changeBranch = function(keyword){
  1190. if(keyword === undefined){
  1191. $scope.assign.duty = undefined;
  1192. $scope.dutyDeptList = [];
  1193. $scope.assign.group = undefined;
  1194. $scope.group = [];
  1195. $scope.assign.user = undefined;
  1196. $scope.user = [];
  1197. }
  1198. if(!$scope.assign.branch){
  1199. $scope.dutyDeptList = [];
  1200. return;
  1201. }
  1202. api_user_data.fetchDataList('dutyDepartment', {
  1203. "idx": 0,
  1204. "sum": 100,
  1205. "dutyDepartment":{
  1206. branch:$scope.assign.branch.id,
  1207. dept:keyword,
  1208. selectType: "pinyin_qs"
  1209. }
  1210. }).then(function (data) {
  1211. if(data.status == 200){
  1212. $scope.dutyDeptList = data.list;
  1213. }else{
  1214. SweetAlert.swal({
  1215. title: "系统错误!",
  1216. text: "请刷新重试!",
  1217. type: "error"
  1218. });
  1219. }
  1220. })
  1221. }
  1222. // 修改责任科室
  1223. $scope.changeDuty = function(keyword){
  1224. if(keyword === undefined){
  1225. $scope.assign.user = undefined;
  1226. $scope.user = [];
  1227. $scope.assign.group = undefined;
  1228. $scope.group = [];
  1229. }
  1230. api_user_data.fetchDataList('group', {
  1231. "idx": 0,
  1232. "sum": 9999,
  1233. "group":{
  1234. duty:$scope.assign.duty,
  1235. selectType: "nouser"
  1236. }
  1237. }).then(function (data) {
  1238. if(data.status == 200){
  1239. $scope.group = data.list;
  1240. }else{
  1241. SweetAlert.swal({
  1242. title: "系统错误!",
  1243. text: "请刷新重试!",
  1244. type: "error"
  1245. });
  1246. }
  1247. })
  1248. }
  1249. $scope.changeGroup = function(item){
  1250. // $scope.assign.group = item.id;
  1251. $scope.assign.user = undefined;
  1252. $scope.user = [];
  1253. $scope.getUsers(item.id)
  1254. }
  1255. $scope.ok = function () {
  1256. if ($scope.assign.isRadioUser == 1 && !$scope.assign.user){
  1257. Alert.swal({
  1258. title: "操作失败",
  1259. text: "请选择转派对象信息!",
  1260. type: "error"
  1261. });
  1262. return;
  1263. }
  1264. if ($scope.assign.isRadioUser == 0 && !$scope.assign.group){
  1265. Alert.swal({
  1266. title: "操作失败",
  1267. text: "请选择工作组!",
  1268. type: "error"
  1269. });
  1270. return;
  1271. }
  1272. let postData = {};
  1273. if($scope.assign.user && $scope.assign.user.id){
  1274. // 派人
  1275. postData ={ incident: {...model, ...{assignee: $scope.assign.user.id}} };
  1276. } else if($scope.assign.group && $scope.assign.group.id){
  1277. // 派组
  1278. postData ={ incident: {...model, ...{candidateGroups: $scope.assign.group.id}} };
  1279. }
  1280. $rootScope.isMask = true;
  1281. api_flow.accept("assign", postData).then(function (response) {
  1282. console.log(response)
  1283. $rootScope.isMask = false;
  1284. if (response.state == 200) {
  1285. Alert.swal({
  1286. title: "操作成功!",
  1287. confirmButtonColor: "#007AFF",
  1288. type: "success"
  1289. });
  1290. $modalInstance.close('success');
  1291. } else {
  1292. Alert.swal({
  1293. title: "操作失败",
  1294. text: "操作失败, 请稍后再试!",
  1295. type: "error"
  1296. });
  1297. }
  1298. });
  1299. }
  1300. $scope.cancel = function () {
  1301. $modalInstance.dismiss('cancel');
  1302. }
  1303. },
  1304. size: 'sm',
  1305. resolve: {
  1306. api_bpm: function () {
  1307. return api_bpm;
  1308. },
  1309. modelData: function () {
  1310. return model;
  1311. },
  1312. currentUserId: function () {
  1313. return loginUser.id;
  1314. },
  1315. Alert: function () {
  1316. return SweetAlert;
  1317. },
  1318. api_user_data: function () {
  1319. return api_user_data;
  1320. }
  1321. }
  1322. });
  1323. modalInstance.result.then(function (selectedItem) {
  1324. if (selectedItem == 'success') {
  1325. $scope.refreshData('expand-right', defaultFilterData);
  1326. }
  1327. });
  1328. }
  1329. // 转派弹窗
  1330. $scope.toTransfer = function (model) {
  1331. console.log(model)
  1332. var modalInstance = $modal.open({
  1333. templateUrl: 'assets/views/incident/tpl/toTransfer.tpl.html',
  1334. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  1335. console.log(model,loginUser);
  1336. $scope.assign = {
  1337. duty:model.duty,
  1338. user:undefined,
  1339. group:undefined,
  1340. isRadioGroup: 0,
  1341. }
  1342. $scope.user = [];
  1343. $scope.group = [];
  1344. //获取责任科室下面的用户
  1345. $scope.getUsers = function(){
  1346. $scope.user = [];
  1347. var postData = {
  1348. "idx": 0,
  1349. "sum": 9999,
  1350. user: {
  1351. currentDuty: $scope.assign.duty.id,
  1352. roledata: { rolecode: "first-line support" },
  1353. roledata2: { rolecode: "second-line support" },
  1354. selectType: "1",
  1355. selectDetails:1,
  1356. simple: true,
  1357. }
  1358. }
  1359. api_user_data.fetchDataList('user', postData).then(function (data) {
  1360. $scope.user = data.list;
  1361. })
  1362. }
  1363. $scope.getUsers();
  1364. //获取责任科室下面的组
  1365. $scope.getGroups = function(){
  1366. $scope.group = [];
  1367. var postData = {
  1368. "idx": 0,
  1369. "sum": 9999,
  1370. group: {
  1371. duty: $scope.assign.duty,
  1372. selectType: "nouser",
  1373. }
  1374. }
  1375. api_user_data.fetchDataList('group', postData).then(function (data) {
  1376. $scope.group = data.list;
  1377. })
  1378. }
  1379. $scope.getGroups();
  1380. // 修改是否转派到组
  1381. $scope.changeRadioGroup = function(){
  1382. $scope.assign.group = undefined;
  1383. $scope.assign.user = undefined;
  1384. }
  1385. $scope.ok = function () {
  1386. if ($scope.assign.isRadioGroup == 0 && !$scope.assign.user){
  1387. Alert.swal({
  1388. title: "操作失败",
  1389. text: "请选择转派对象信息!",
  1390. type: "error"
  1391. });
  1392. return;
  1393. }
  1394. if ($scope.assign.isRadioGroup == 1 && !$scope.assign.group){
  1395. Alert.swal({
  1396. title: "操作失败",
  1397. text: "请选择工作组!",
  1398. type: "error"
  1399. });
  1400. return;
  1401. }
  1402. let postData = {};
  1403. if($scope.assign.user && $scope.assign.user.id){
  1404. // 派人
  1405. postData ={ incident: {...model, ...{assignee: $scope.assign.user.id}} };
  1406. } else if($scope.assign.group && $scope.assign.group.id){
  1407. // 派组
  1408. postData ={ incident: {...model, ...{candidateGroups: $scope.assign.group.id}} };
  1409. }
  1410. $rootScope.isMask = true;
  1411. api_flow.accept("redeploy", postData).then(function (response) {
  1412. console.log(response)
  1413. $rootScope.isMask = false;
  1414. if (response.state == 200) {
  1415. Alert.swal({
  1416. title: "操作成功!",
  1417. confirmButtonColor: "#007AFF",
  1418. type: "success"
  1419. });
  1420. $modalInstance.close('success');
  1421. } else {
  1422. Alert.swal({
  1423. title: "操作失败",
  1424. text: "操作失败, 请稍后再试!",
  1425. type: "error"
  1426. });
  1427. }
  1428. });
  1429. }
  1430. $scope.cancel = function () {
  1431. $modalInstance.dismiss('cancel');
  1432. }
  1433. },
  1434. size: 'sm',
  1435. resolve: {
  1436. api_bpm: function () {
  1437. return api_bpm;
  1438. },
  1439. modelData: function () {
  1440. return model;
  1441. },
  1442. currentUserId: function () {
  1443. return loginUser.id;
  1444. },
  1445. Alert: function () {
  1446. return SweetAlert;
  1447. },
  1448. api_user_data: function () {
  1449. return api_user_data;
  1450. }
  1451. }
  1452. });
  1453. modalInstance.result.then(function (selectedItem) {
  1454. if (selectedItem == 'success') {
  1455. $scope.refreshData('expand-right', defaultFilterData);
  1456. }
  1457. });
  1458. }
  1459. // 删除事件
  1460. $scope.delSj = function(model){
  1461. console.log(model);
  1462. SweetAlert.swal({
  1463. title: "确认删除?",
  1464. text: "删除的数据不可恢复,请确认继续操作!",
  1465. type: "warning",
  1466. showCancelButton: true,
  1467. confirmButtonColor: "#DD6B55",
  1468. confirmButtonText: "继续删除",
  1469. cancelButtonText: "取消操作",
  1470. closeOnConfirm: false,
  1471. closeOnCancel: false
  1472. }, function (isConfirm) {
  1473. if (isConfirm) {
  1474. api_bpm_schedule.del(model.id).then(function (response) {
  1475. if (response.status == 200) {
  1476. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  1477. $scope.refreshData('expand-right');
  1478. } else {
  1479. SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
  1480. }
  1481. });
  1482. } else {
  1483. SweetAlert.swal("操作取消", "数据安全", "error");
  1484. }
  1485. });
  1486. }
  1487. // 继续创建
  1488. $scope.storageSj = function(model){
  1489. console.log(model);
  1490. $rootScope.newOrder({incident: model});
  1491. }
  1492. // 新增维修记录弹窗
  1493. $scope.toHandlerLog = function (model) {
  1494. console.log(model)
  1495. var modalInstance = $modal.open({
  1496. templateUrl: 'assets/views/incident/tpl/toHandlerLog.tpl.html',
  1497. controller: function ($scope, $modalInstance, api_bpm_domain,api_bpm_data, modelData, currentUserId, Alert, api_user_data,api_statistic) {
  1498. console.log(model,loginUser);
  1499. $scope.f = {
  1500. maintenanceMode: '',
  1501. estimatedNumberOfDays: ''
  1502. }
  1503. $scope.handlerLog = '';
  1504. $scope.user = [];
  1505. $scope.logs = [];
  1506. $scope.modes = [];
  1507. $scope.getModes=function(){
  1508. var data={
  1509. "idx":0,
  1510. "sum":999,
  1511. dictionary:{key:'repair_type'}
  1512. }
  1513. api_statistic.tableData(data,"dictionary").then(function(res){
  1514. $scope.modes=res.list
  1515. })
  1516. }
  1517. $scope.getModes();
  1518. $scope.getLogs=function(){
  1519. var data={
  1520. "idx":0,
  1521. "sum":999,
  1522. dictionary:{key:'processingLog'}
  1523. }
  1524. api_statistic.tableData(data,"dictionary").then(function(res){
  1525. $scope.logs=res.list
  1526. })
  1527. }
  1528. $scope.getLogs();
  1529. $scope.copyTo = function(value){
  1530. $scope.handlerLog += value;
  1531. }
  1532. $scope.ok = function () {
  1533. if (!$scope.f.maintenanceMode){
  1534. Alert.swal({
  1535. title: "操作失败",
  1536. text: "请选择维修方式!",
  1537. type: "error"
  1538. });
  1539. return;
  1540. }
  1541. if (!$scope.f.estimatedNumberOfDays){
  1542. Alert.swal({
  1543. title: "操作失败",
  1544. text: "请选择预估天数!",
  1545. type: "error"
  1546. });
  1547. return;
  1548. }
  1549. if (!$scope.handlerLog.trim()){
  1550. Alert.swal({
  1551. title: "操作失败",
  1552. text: "请填写备注!",
  1553. type: "error"
  1554. });
  1555. return;
  1556. }
  1557. $rootScope.isMask = true;
  1558. api_bpm_data.addData('operationLog',{
  1559. operationLog:{
  1560. opType:'handlerLog',
  1561. opValue:$scope.handlerLog,
  1562. extra1:model.id,
  1563. repairType: $scope.f.maintenanceMode,
  1564. expectedDay: $scope.f.estimatedNumberOfDays
  1565. }
  1566. }).then(function(response){
  1567. console.log(response)
  1568. $rootScope.isMask = false;
  1569. if (response.status == 200) {
  1570. Alert.swal({
  1571. title: "操作成功!",
  1572. confirmButtonColor: "#007AFF",
  1573. type: "success"
  1574. });
  1575. $modalInstance.close('success');
  1576. } else {
  1577. Alert.swal({
  1578. title: "操作失败",
  1579. text: "操作失败, 请稍后再试!",
  1580. type: "error"
  1581. });
  1582. }
  1583. });
  1584. }
  1585. $scope.cancel = function () {
  1586. $modalInstance.dismiss('cancel');
  1587. }
  1588. },
  1589. size: 'lg',
  1590. resolve: {
  1591. api_bpm: function () {
  1592. return api_bpm;
  1593. },
  1594. modelData: function () {
  1595. return model;
  1596. },
  1597. currentUserId: function () {
  1598. return loginUser.id;
  1599. },
  1600. Alert: function () {
  1601. return SweetAlert;
  1602. },
  1603. api_user_data: function () {
  1604. return api_user_data;
  1605. },
  1606. api_statistic: function () {
  1607. return api_statistic;
  1608. }
  1609. }
  1610. });
  1611. modalInstance.result.then(function (selectedItem) {
  1612. if (selectedItem == 'success') {
  1613. $scope.refreshData('expand-right', defaultFilterData);
  1614. }
  1615. });
  1616. }
  1617. // 设置责任科室
  1618. $scope.setDuty = function (model) {
  1619. console.log(model)
  1620. var modalInstance = $modal.open({
  1621. templateUrl: 'assets/views/incident/tpl/setDuty.tpl.html',
  1622. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  1623. console.log(model,loginUser);
  1624. $scope.assign = {
  1625. branch:undefined,
  1626. duty:undefined,
  1627. }
  1628. $scope.hospitalList = [];
  1629. $scope.dutyDeptList = [];
  1630. // 获取院区
  1631. $scope.getHospitals = function(){
  1632. //跨科室转派
  1633. api_user_data.fetchDataList('branch', {
  1634. "idx": 0,
  1635. "sum": 100
  1636. }).then(function (data) {
  1637. if(data.status == 200){
  1638. $scope.hospitalList = data.list;
  1639. if($scope.assign.duty){
  1640. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $scope.assign.duty.branch);
  1641. }else{
  1642. if($rootScope.user.duty){
  1643. // 当前的所属责任科室
  1644. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  1645. $scope.assign.duty = $rootScope.user.duty;
  1646. $scope.changeDuty();
  1647. }else if($rootScope.user.branch){
  1648. // 当前的所属院区
  1649. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  1650. }
  1651. }
  1652. }else{
  1653. SweetAlert.swal({
  1654. title: "系统错误!",
  1655. text: "请刷新重试!",
  1656. type: "error"
  1657. });
  1658. }
  1659. })
  1660. }
  1661. $scope.getHospitals();
  1662. // 修改院区
  1663. $scope.changeBranch = function(keyword){
  1664. if(keyword === undefined){
  1665. $scope.assign.duty = undefined;
  1666. $scope.dutyDeptList = [];
  1667. }
  1668. if(!$scope.assign.branch){
  1669. $scope.dutyDeptList = [];
  1670. return;
  1671. }
  1672. api_user_data.fetchDataList('dutyDepartment', {
  1673. "idx": 0,
  1674. "sum": 100,
  1675. "dutyDepartment":{
  1676. branch:$scope.assign.branch.id,
  1677. dept:keyword,
  1678. selectType: "pinyin_qs"
  1679. }
  1680. }).then(function (data) {
  1681. if(data.status == 200){
  1682. $scope.dutyDeptList = data.list;
  1683. }else{
  1684. SweetAlert.swal({
  1685. title: "系统错误!",
  1686. text: "请刷新重试!",
  1687. type: "error"
  1688. });
  1689. }
  1690. })
  1691. }
  1692. $scope.ok = function () {
  1693. if (!$scope.assign.duty){
  1694. Alert.swal({
  1695. title: "操作失败",
  1696. text: "请选择责任科室!",
  1697. type: "error"
  1698. });
  1699. return;
  1700. }
  1701. $rootScope.isMask = true;
  1702. api_bpm_domain.changeIncidentDuty({orderId: model.id, dutyId: $scope.assign.duty.id}).then(function (response) {
  1703. console.log(response)
  1704. $rootScope.isMask = false;
  1705. if (response.status == 200) {
  1706. Alert.swal({
  1707. title: "操作成功!",
  1708. confirmButtonColor: "#007AFF",
  1709. type: "success"
  1710. });
  1711. $modalInstance.close('success');
  1712. } else {
  1713. Alert.swal({
  1714. title: "操作失败",
  1715. text: "操作失败, 请稍后再试!",
  1716. type: "error"
  1717. });
  1718. }
  1719. });
  1720. }
  1721. $scope.cancel = function () {
  1722. $modalInstance.dismiss('cancel');
  1723. }
  1724. },
  1725. size: 'sm',
  1726. resolve: {
  1727. api_bpm: function () {
  1728. return api_bpm;
  1729. },
  1730. modelData: function () {
  1731. return model;
  1732. },
  1733. currentUserId: function () {
  1734. return loginUser.id;
  1735. },
  1736. Alert: function () {
  1737. return SweetAlert;
  1738. },
  1739. api_user_data: function () {
  1740. return api_user_data;
  1741. }
  1742. }
  1743. });
  1744. modalInstance.result.then(function (selectedItem) {
  1745. if (selectedItem == 'success') {
  1746. $scope.refreshData('expand-right', defaultFilterData);
  1747. }
  1748. });
  1749. }
  1750. if ($stateParams.model) {
  1751. if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
  1752. $scope.searchType = JSON.parse($stateParams.model).searchType;
  1753. } else {
  1754. $scope.searchType = "todo";
  1755. }
  1756. } else {
  1757. $scope.searchType = "todo";
  1758. }
  1759. if ($rootScope.user.group) {
  1760. var defaultFilterData = {
  1761. "searchType": "todo",
  1762. "idx": 0,
  1763. "sum": mun
  1764. };
  1765. } else {
  1766. var defaultFilterData = {
  1767. "searchType": "todo",
  1768. "idx": 0,
  1769. "sum": mun
  1770. };
  1771. }
  1772. if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
  1773. defaultFilterData['searchType'] = $rootScope.search.incident;
  1774. $scope.searchType = $rootScope.search.incident;
  1775. }
  1776. $scope.ldloading = {};
  1777. //事件类型筛选
  1778. console.log($state);
  1779. if($state.params.tab){
  1780. $scope.searchstate = $state.params.tab;
  1781. }else{
  1782. $scope.searchstate = 'todo';
  1783. }
  1784. $scope.onChange = function (searchType) {
  1785. if(searchType === 'all_del'){
  1786. var obj = $scope.state.find(function(v){return v.id == 1708});
  1787. $scope.othcode = {state:obj};
  1788. $scope.isDisabledState = true;
  1789. }else{
  1790. $scope.isDisabledState = false;
  1791. }
  1792. $scope.searchstate = searchType;
  1793. $scope.chiceIncident($scope.searchkeys,$scope.othcode.state);
  1794. }
  1795. // 是否逾期下拉框选择seimin
  1796. $scope.selectTypeChange = function(){
  1797. console.log($scope.searchkeys.selectType,66666);
  1798. if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
  1799. $scope.searchkeys.selectType = {id:'2',name:'是'};
  1800. }
  1801. var ids = $scope.searchkeys.selectType.id
  1802. if(defaultFilterData.incident){
  1803. defaultFilterData.incident.selectType = ids;//seimin
  1804. }else{
  1805. defaultFilterData.incident = {
  1806. selectType:ids
  1807. };
  1808. }
  1809. defaultFilterData.searchType = 'all';
  1810. console.log(defaultFilterData,2222)
  1811. $scope.onChange('all');
  1812. }
  1813. //获取列表数据
  1814. $scope.refreshData = function (style, filterData) {
  1815. console.log(filterData,9090)
  1816. if (filterData && filterData.incident && filterData.incident.area) {
  1817. filterData.incident.place = {
  1818. id: filterData.incident.place ? filterData.incident.place.id : '',
  1819. area: filterData.incident.area
  1820. }
  1821. delete filterData.incident.area
  1822. }
  1823. $scope.ldloading[style.replace('-', '_')] = true;
  1824. if (angular.isUndefined(filterData)) {
  1825. filterData = defaultFilterData;
  1826. if ($scope.searchType) {
  1827. filterData.searchType = $scope.searchType;
  1828. if (filterData.searchType == 'overDate') {
  1829. $scope.searchstate = 'overDate';
  1830. }
  1831. }
  1832. if($state.params.tab){
  1833. $scope.searchstate = $state.params.tab;
  1834. filterData.searchType = $state.params.tab;
  1835. filterData.idx = 0;
  1836. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  1837. }else{
  1838. $scope.searchstate = filterData.searchType;
  1839. }
  1840. if($state.params.date == 'today'){
  1841. $scope.othcode = {};
  1842. $scope.searchkeys.acceptDate = new Date();
  1843. $scope.searchkeys.acceptDateEnd = new Date();
  1844. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  1845. }else{
  1846. $scope.searchkeys.acceptDate = null;
  1847. $scope.searchkeys.acceptDateEnd = null;
  1848. }
  1849. if($state.params.state){
  1850. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  1851. $scope.othcode = {state:obj};
  1852. filterData.incident = {statusId: $state.params.state};
  1853. }
  1854. } else {
  1855. filterData.searchType = $scope.searchstate;
  1856. }
  1857. console.log(filterData,11111);
  1858. if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
  1859. $scope.searchkeys.selectType = {id:'2',name:'是'};
  1860. if(filterData.incident&&filterData.incident.selectType){
  1861. filterData.incident.selectType = '2';
  1862. }else{
  1863. filterData.incident = {
  1864. selectType : '2'
  1865. }
  1866. }
  1867. window.sessionStorage.removeItem('isGoyuqi');
  1868. }
  1869. $scope.myData = [];
  1870. $scope.memoryfilterData = filterData;
  1871. $scope.gridOptions['sum'] = filterData.sum;
  1872. // 如果是全部,则根据权限查询
  1873. if(filterData.searchType == 'all'){
  1874. if(!filterData.incident){
  1875. filterData.incident = {};
  1876. }
  1877. if($rootScope.user.duty){
  1878. // 当前的所属责任科室
  1879. filterData.incident.duty = $rootScope.user.duty;
  1880. }else if($rootScope.user.branch){
  1881. // 当前的所属院区
  1882. filterData.incident.branch = $rootScope.user.branch.id;
  1883. }
  1884. }
  1885. if(filterData.searchType == 'all'){
  1886. //全部事件
  1887. api_user_data.fetchDataList('incident', filterData).then(function (data) {
  1888. if (data.list) {
  1889. var myData = Restangular.stripRestangular(data);
  1890. $scope.gridOptions['totalItems'] = myData.totalNum;
  1891. $scope.myData = myData.list;
  1892. for (var i = 0; i < $scope.myData.length; i++) {
  1893. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  1894. }
  1895. } else {
  1896. SweetAlert.swal({
  1897. title: "系统错误",
  1898. text: "请稍后再试!",
  1899. type: "error"
  1900. });
  1901. }
  1902. $scope.ldloading[style.replace('-', '_')] = false;
  1903. }, function () {
  1904. $scope.ldloading[style.replace('-', '_')] = false;
  1905. });
  1906. }else if(filterData.searchType == 'done'){
  1907. //与我关联
  1908. api_flow.owns(filterData).then(function (data) {
  1909. if (data.data.data) {
  1910. var myData = Restangular.stripRestangular(data.data);
  1911. $scope.gridOptions['totalItems'] = myData.resultCount;
  1912. $scope.myData = myData.data;
  1913. for (var i = 0; i < $scope.myData.length; i++) {
  1914. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  1915. }
  1916. } else {
  1917. SweetAlert.swal({
  1918. title: "系统错误",
  1919. text: "请稍后再试!",
  1920. type: "error"
  1921. });
  1922. }
  1923. $scope.ldloading[style.replace('-', '_')] = false;
  1924. }, function () {
  1925. $scope.ldloading[style.replace('-', '_')] = false;
  1926. });
  1927. }else{
  1928. // 非全部事件
  1929. api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
  1930. if (data.data) {
  1931. var myData = Restangular.stripRestangular(data);
  1932. $scope.gridOptions['totalItems'] = myData.resultCount;
  1933. $scope.myData = myData.data;
  1934. for (var i = 0; i < $scope.myData.length; i++) {
  1935. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  1936. }
  1937. } else {
  1938. SweetAlert.swal({
  1939. title: "系统错误",
  1940. text: "请稍后再试!",
  1941. type: "error"
  1942. });
  1943. }
  1944. $scope.ldloading[style.replace('-', '_')] = false;
  1945. }, function () {
  1946. $scope.ldloading[style.replace('-', '_')] = false;
  1947. });
  1948. }
  1949. };
  1950. $scope.refreshData2 = function (style, filterData) {
  1951. $scope.ldloading[style.replace('-', '_')] = true;
  1952. if (angular.isUndefined(filterData)) {
  1953. filterData = defaultFilterData;
  1954. if ($scope.searchType) {
  1955. filterData.searchType = $scope.searchType;
  1956. if (filterData.searchType == 'overDate') {
  1957. $scope.searchstate = 'overDate';
  1958. }
  1959. }
  1960. }else{
  1961. filterData.searchType = $scope.searchstate;
  1962. }
  1963. $scope.myData = [];
  1964. $scope.memoryfilterData = filterData;
  1965. $scope.gridOptions['sum'] = filterData.sum;
  1966. // 如果是全部,则根据权限查询
  1967. if(filterData.searchType == 'all'){
  1968. if(!filterData.incident){
  1969. filterData.incident = {};
  1970. }
  1971. if($rootScope.user.duty){
  1972. // 当前的所属责任科室
  1973. filterData.incident.duty = $rootScope.user.duty;
  1974. }else if($rootScope.user.branch){
  1975. // 当前的所属院区
  1976. filterData.incident.branch = $rootScope.user.branch.id;
  1977. }
  1978. }
  1979. if(filterData.searchType == 'all'){
  1980. //全部事件
  1981. api_user_data.fetchDataList('incident', filterData).then(function (data) {
  1982. if (data.list) {
  1983. var myData = Restangular.stripRestangular(data);
  1984. $scope.gridOptions['totalItems'] = myData.totalNum;
  1985. $scope.myData = myData.list;
  1986. for (var i = 0; i < $scope.myData.length; i++) {
  1987. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  1988. }
  1989. } else {
  1990. SweetAlert.swal({
  1991. title: "系统错误",
  1992. text: "请稍后再试!",
  1993. type: "error"
  1994. });
  1995. }
  1996. $scope.ldloading[style.replace('-', '_')] = false;
  1997. }, function () {
  1998. $scope.ldloading[style.replace('-', '_')] = false;
  1999. });
  2000. }else if(filterData.searchType == 'done'){
  2001. //与我关联
  2002. api_flow.owns(filterData).then(function (data) {
  2003. if (data.data.data) {
  2004. var myData = Restangular.stripRestangular(data.data);
  2005. $scope.gridOptions['totalItems'] = myData.resultCount;
  2006. $scope.myData = myData.data;
  2007. for (var i = 0; i < $scope.myData.length; i++) {
  2008. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2009. }
  2010. } else {
  2011. SweetAlert.swal({
  2012. title: "系统错误",
  2013. text: "请稍后再试!",
  2014. type: "error"
  2015. });
  2016. }
  2017. $scope.ldloading[style.replace('-', '_')] = false;
  2018. }, function () {
  2019. $scope.ldloading[style.replace('-', '_')] = false;
  2020. });
  2021. }else{
  2022. api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
  2023. if (data.data) {
  2024. var myData = Restangular.stripRestangular(data);
  2025. $scope.gridOptions['totalItems'] = myData.resultCount;
  2026. $scope.myData = myData.data;
  2027. for (var i = 0; i < $scope.myData.length; i++) {
  2028. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2029. }
  2030. } else {
  2031. SweetAlert.swal({
  2032. title: "系统错误",
  2033. text: "请稍后再试!",
  2034. type: "error"
  2035. });
  2036. }
  2037. $scope.ldloading[style.replace('-', '_')] = false;
  2038. }, function () {
  2039. $scope.ldloading[style.replace('-', '_')] = false;
  2040. });
  2041. }
  2042. };
  2043. // 进入页面时111
  2044. if(window.sessionStorage.getItem('isGoyuqi') === 'yes'){
  2045. $scope.selectTypeChange();
  2046. }else{
  2047. $scope.refreshData('expand-right');
  2048. }
  2049. $scope.timer = $interval(function () {
  2050. $scope.jry_refresh()
  2051. }, $rootScope.refreshTime);
  2052. $scope.$on('$destroy', function () {
  2053. $interval.cancel($scope.timer)
  2054. });
  2055. }]);
  2056. //操作按钮权限控制
  2057. app.controller('IncidentOperCtrl', ['$rootScope', '$scope', '$state', function ($rootScope, $scope, $state) {
  2058. var loginUser = $rootScope.user;
  2059. $scope.user = $rootScope.user;
  2060. $scope.chuli = false;
  2061. $scope.qiangdan = false;
  2062. $scope.huifang = false;
  2063. $scope.delFlag = false;
  2064. $scope.storageFlag = false;
  2065. $scope.editFlag = false;//编辑
  2066. $scope.assignFlag = false;//指派
  2067. $scope.transferFlag = false;//转派
  2068. $scope.shijianliebiao_duty = false;//设置责任科室
  2069. for (var i = 0; i < loginUser.menu.length; i++) {
  2070. if (loginUser.menu[i].link == "shijianliebiao_chuli") {
  2071. $scope.chuli = true
  2072. }
  2073. if (loginUser.menu[i].link == "shijianliebiao_qiangdan") {
  2074. $scope.qiangdan = true
  2075. }
  2076. if (loginUser.menu[i].link == "shijianliebiao_huifang") {
  2077. $scope.huifang = true
  2078. }
  2079. if (loginUser.menu[i].link == "shijianliebiao_del") {
  2080. $scope.delFlag = true
  2081. }
  2082. if (loginUser.menu[i].link == "shijianliebiao_build") {
  2083. $scope.storageFlag = true
  2084. }
  2085. if (loginUser.menu[i].link == "shijianliebiao_edit") {
  2086. $scope.editFlag = true
  2087. }
  2088. if (loginUser.menu[i].link == "shijianliebiao_assign") {
  2089. $scope.assignFlag = true
  2090. }
  2091. if (loginUser.menu[i].link == "shijianliebiao_transfer") {
  2092. $scope.transferFlag = true
  2093. }
  2094. if (loginUser.menu[i].link == "shijianliebiao_duty") {
  2095. $scope.shijianliebiao_duty = true
  2096. }
  2097. }
  2098. $scope.up = true;
  2099. $scope.fuwutaiRenYuan = false;//服务台人员
  2100. for (var i = 0; i < $rootScope.user.role.length; i++) {
  2101. if ($rootScope.user.role[i].role == '事件经理') {
  2102. $scope.up = false;
  2103. }
  2104. if ($rootScope.user.role[i].id == 29701) {
  2105. $scope.fuwutaiRenYuan = true;
  2106. }
  2107. }
  2108. if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  2109. // 当前登陆人和当前处理人相同,并且状态非已关闭
  2110. if ($rootScope.user.id == $scope.item.handlerUser.id && $scope.item.state.id != 1546) {
  2111. $scope.item.chaozuoPower = true;
  2112. }
  2113. }
  2114. $rootScope.callid = $scope.item.callID;
  2115. if ($scope.item.callID) {
  2116. $scope.item.listen = true;
  2117. } else {
  2118. $scope.item.listen = false;
  2119. }
  2120. $rootScope.user.group.forEach(function (item, v) {
  2121. if($scope.item.currentLog){
  2122. if (item.id == $scope.item.currentLog.groupId) {
  2123. $scope.item.tiquPower = true;
  2124. }
  2125. }
  2126. })
  2127. //修改页面显示判断
  2128. $scope.jry_modify = function (item) {
  2129. var arrFlag = ['pending','handler'];
  2130. var stateFlag = arrFlag.includes(item.state.value)
  2131. return stateFlag && $scope.editFlag;
  2132. }
  2133. // 回访操作权限
  2134. for (var obj in $rootScope.user.role) {
  2135. if ($rootScope.user.role[obj].rolecode == 'call center') {
  2136. if ($scope.item.state.id == 1546) {
  2137. $scope.item.huifang = true;
  2138. } else {}
  2139. }
  2140. }
  2141. $scope.edit = function () {
  2142. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  2143. }
  2144. $scope.changeCenter = function () {
  2145. $scope.colobject.grid.appScope.changeClick($scope.item);
  2146. }
  2147. $scope.visit = function () {
  2148. $scope.colobject.grid.appScope.visit($scope.item);
  2149. }
  2150. // 指派
  2151. $scope.toAssign = function () {
  2152. $scope.colobject.grid.appScope.toAssign($scope.item);
  2153. }
  2154. // 转派
  2155. $scope.toTransfer = function () {
  2156. $scope.colobject.grid.appScope.toTransfer($scope.item);
  2157. }
  2158. // 删除事件
  2159. $scope.delSj = function () {
  2160. $scope.colobject.grid.appScope.delSj($scope.item);
  2161. }
  2162. // 继续创建
  2163. $scope.storageSj = function () {
  2164. $scope.colobject.grid.appScope.storageSj($scope.item);
  2165. }
  2166. // 新增维修记录
  2167. $scope.toHandlerLog = function () {
  2168. $scope.colobject.grid.appScope.toHandlerLog($scope.item);
  2169. }
  2170. // 设置责任科室
  2171. $scope.setDuty = function () {
  2172. $scope.colobject.grid.appScope.setDuty($scope.item);
  2173. }
  2174. $scope.play = function () { //record
  2175. $scope.colobject.grid.appScope.play($scope.item);
  2176. }
  2177. $scope.handler = function () {
  2178. $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
  2179. }
  2180. //查看
  2181. $scope.toDetail = function (data) {
  2182. console.log(data,$rootScope.isFuwutai);
  2183. if($rootScope.isFuwutai){
  2184. //角色是服务台人员
  2185. $state.go('app.incident.incidentDetail', {
  2186. id: data.id,
  2187. });
  2188. }else{
  2189. window.open(location.origin+'/#/app/incident/incidentDetail/'+data.id);
  2190. }
  2191. };
  2192. }]);
  2193. //操作按钮
  2194. app.directive('incidentoperator', function () {
  2195. return {
  2196. restrict: 'E',
  2197. scope: {
  2198. item: '=',
  2199. colobject: '='
  2200. },
  2201. controller: 'IncidentOperCtrl',
  2202. template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" style="text-align:left;">' +
  2203. '<a ng-click="toDetail(item)" class="bianjifont" >查看</a>' +
  2204. '<a ng-click="changeCenter()" ng-show="jry_modify(item)" class="luyinfont">编辑</a>' +
  2205. '<a ng-click="delSj()" ng-show="{{delFlag && item.state.value !== \'deleted\'}}" class="assign" >删除</a>' +
  2206. '<a ng-click="storageSj()" ng-show="{{storageFlag && item.state.value === \'storage\'}}" class="assign" >继续创建</a><br>' +
  2207. '<a ng-click="edit()" ng-show="{{item.chaozuoPower && chuli}}" class="bianjifont">处理</a>' +
  2208. '<a ng-click="handler()" ng-show="{{item.state.value == \'pending\' && ((item.currentLog && item.currentLog.workerId == user.id) || item.tiquPower) && qiangdan}}" class="bianjifont" >接单</a>' +
  2209. '<a ng-click="visit()" ng-show="{{item.huifang && huifang}}" class="bianjifont">回访</a>' +
  2210. '<a ng-click="toAssign()" ng-show="{{(item.state.value == \'pending\' || item.state.value == \'handler\') && assignFlag}}" class="assign" >指派</a>' +
  2211. '<a ng-click="toTransfer()" ng-show="{{item.state.value == \'handler\' && item.handlingPersonnelUser && item.handlingPersonnelUser.id == user.id && !assignFlag && transferFlag}}" class="assign" >转派</a>' +
  2212. '<a ng-click="toHandlerLog()" ng-show="{{item.state.value == \'handler\'}}" class="assign" >维修进度</a>' +
  2213. '<a ng-click="setDuty()" ng-show="{{shijianliebiao_duty && (item.state.value == \'resolved\' || item.state.value == \'close\')}}" class="assign" >设置责任科室</a>' +
  2214. '</div></div>'
  2215. };
  2216. });