incidentCtrl.js 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581
  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.state.value == "resolved" || row.entity.state.value == "close") ? (row.entity.handlingPersonnelUser ? row.entity.handlingPersonnelUser.name : "无") : (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. if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).incident) {
  595. angular.forEach($scope.state, function (item) {
  596. if (item.id == JSON.parse(sessionStorage.getItem("searchincident")).incident.statusId) {
  597. $scope.othcode = {
  598. "state": item
  599. };
  600. }
  601. })
  602. }
  603. }
  604. }
  605. })
  606. if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).incident) {
  607. if (JSON.parse(sessionStorage.getItem("searchincident")).incident) {
  608. $scope.searchkeys = JSON.parse(sessionStorage.getItem("searchincident")).incident;
  609. }
  610. if ($scope.searchkeys.acceptDate) {
  611. $scope.searchkeys.acceptDate = new Date($scope.searchkeys.acceptDate);
  612. }
  613. if ($scope.searchkeys.acceptDateEnd) {
  614. $scope.searchkeys.acceptDateEnd = new Date($scope.searchkeys.acceptDateEnd);
  615. }
  616. }
  617. $scope.clear = function () {
  618. $scope.searchkeys = {};
  619. $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  620. $scope.othcode = {};
  621. $scope.try_async_load();
  622. var fildata = {
  623. "assignee": loginUser.id,
  624. "candidateGroups": loginuserGroup,
  625. "searchType": JSON.parse(sessionStorage.getItem("searchincident")).searchType,
  626. "idx": JSON.parse(sessionStorage.getItem("searchincident")).idx,
  627. "sum": JSON.parse(sessionStorage.getItem("searchincident")).sum
  628. }
  629. sessionStorage.removeItem("searchincident");
  630. fildata.assignee = loginUser.id;
  631. $scope.memoryfilterData = fildata;
  632. $scope.refreshData('expand-right', fildata);
  633. $interval.cancel($scope.timer);
  634. $scope.timer = $interval(function () {
  635. $scope.jry_refresh()
  636. }, $rootScope.refreshTime);
  637. }
  638. // 刷新
  639. $scope.jry_refresh = function () {
  640. var fildata = {};
  641. if (sessionStorage.searchincident) {
  642. fildata = JSON.parse(sessionStorage.getItem("searchincident"));
  643. } else {
  644. fildata = defaultFilterData;
  645. }
  646. if (fildata.incident && fildata.incident.category) {
  647. delete fildata.incident.category
  648. }
  649. fildata.idx = $scope.jry_idx;
  650. fildata.sum = $scope.jry_sum;
  651. $scope.refreshData2('expand-right', fildata);
  652. console.log($scope.cifilter_classic);
  653. }
  654. // 搜索
  655. $scope.chiceIncident = function (item, stateid) {
  656. if (stateid && stateid.id) {
  657. item.statusId = stateid.id;
  658. } else {
  659. item.statusId = undefined;
  660. }
  661. console.log(item)
  662. var fildata = {};
  663. if (sessionStorage.searchincident) {
  664. fildata = JSON.parse(sessionStorage.getItem("searchincident"));
  665. $scope.gridOptions.paginationCurrentPage = 1;
  666. fildata.idx = 0;
  667. } else {
  668. fildata = defaultFilterData;
  669. }
  670. if (!fildata.incident) {
  671. fildata['incident'] = {};
  672. }
  673. if (item.acceptDate) {
  674. item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD 00:00:00');
  675. }
  676. if (item.acceptDateEnd) {
  677. item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD 23:59:59')
  678. }
  679. var transitiondata = angular.copy(item);
  680. angular.extend(fildata.incident, transitiondata)
  681. sessionStorage['searchincident'] = JSON.stringify(fildata);
  682. $scope.memoryfilterData = fildata;
  683. fildata.assignee = loginUser.id;
  684. // seimin
  685. if($scope.searchstate === 'all_del'){
  686. fildata.searchType = 'all';
  687. }else{
  688. fildata.searchType = $scope.searchstate;
  689. }
  690. console.log(fildata,78777);
  691. if(fildata.searchType === 'all'){
  692. if(fildata.incident&&fildata.incident.selectType){
  693. fildata.incident.selectType = fildata.incident.selectType.id;
  694. }
  695. }else{
  696. if(fildata.incident&&fildata.incident.selectType){
  697. delete fildata.incident.selectType;
  698. }
  699. }
  700. // /seimin
  701. $scope.refreshData('expand-right', fildata);
  702. $interval.cancel($scope.timer);
  703. $scope.timer = $interval(function () {
  704. $scope.jry_refresh()
  705. }, $rootScope.refreshTime);
  706. }
  707. //区域地点过滤
  708. api_user_data.fetchDataList('area', {
  709. "idx": 0,
  710. "sum": 1000
  711. }).then(function (response) {
  712. if (response) {
  713. if (response.status = 200) {
  714. $scope.outarea = response.list;
  715. }
  716. }
  717. })
  718. //报修人
  719. var getRequester = function () {
  720. api_user_data.fetchDataList('requester', {
  721. idx: 0,
  722. sum: 100
  723. }).then(function (data) {
  724. // console.log(data);
  725. $scope.requester = data.list
  726. });
  727. }
  728. getRequester();
  729. //受理人,处理人
  730. var getUser = function (fieldatas, it) {
  731. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  732. if (it == 1) {
  733. $scope.acceptUser = data.list;
  734. } else if (it == 2) {
  735. $scope.handlingPersonnelUser = data.list;
  736. }
  737. });
  738. }
  739. //受理人过滤
  740. $scope.onChangeacceptUser = function (key) {
  741. console.log(key)
  742. var filuser = {
  743. "idx": 0,
  744. "sum": 10,
  745. "user": {
  746. "name": key,
  747. 'selectType': "pinyin_qs"
  748. }
  749. }
  750. getUser(filuser, 1);
  751. }
  752. //处理人过滤
  753. $scope.onChangehandling = function (key) {
  754. var filuser = {
  755. "idx": 0,
  756. "sum": 10,
  757. "user": {
  758. "name": key,
  759. 'selectType': "pinyin_qs"
  760. }
  761. }
  762. getUser(filuser, 2);
  763. }
  764. //报修科室过滤
  765. $scope.onChangeDept = function (key) {
  766. $scope.getDept(key)
  767. }
  768. //地点区域过滤
  769. $scope.onChangearea = function (data) {
  770. delete $scope.searchkeys.place;
  771. if ($scope.memoryfilterData.incident) {
  772. delete $scope.memoryfilterData.incident.place;
  773. }
  774. var fildata = {
  775. "idx": 0,
  776. "sum": 1000,
  777. "place": {
  778. area: {
  779. id: data.area.id
  780. }
  781. }
  782. };
  783. api_user_data.fetchDataList('place', fildata).then(function (response) {
  784. if (response) {
  785. if (response.status = 200) {
  786. $scope.outplace = response.list;
  787. }
  788. }
  789. })
  790. };
  791. $scope.starttime = function (data) {
  792. return moment(new Date(data)).format('YYYY-MM-DD')
  793. }
  794. $scope.overtime = function (data) {
  795. return moment(new Date(data)).format('YYYY-MM-DD HH:mm')
  796. }
  797. $scope.areaplace = function (data) {
  798. var str = '';
  799. str += '<strong>' + data.branchName + '</strong>';
  800. str += (data.place ? (data.place.area ? data.place.area.area : '') : '');
  801. str += (data.place ? (data.place.place ? data.place.place : '') : '');
  802. str += (data.houseNumber ? data.houseNumber : '');
  803. return str || '无';
  804. }
  805. //录音
  806. $scope.play = function (data) {
  807. console.log(data.callID)
  808. var modalInstance = $modal.open({
  809. backdrop: "static",
  810. templateUrl: 'assets/views/incident/tpl/audio.html',
  811. controller: function ($rootScope, $scope, $modalInstance, $sce, $http, api_bpm_data) {
  812. // $rootScope.setbusy();
  813. $scope.datasurl = "";
  814. api_bpm_data.fetchDataList("callrecord", {idx: 0, sum: 1, callrecord: {callAccept: data.callID}}).then(function(data) {
  815. if(data.status == 200){
  816. data.list = data.list || [];
  817. if(data.list.length){
  818. $scope.audioUrl = $sce.trustAsResourceUrl(callIp+data.list[0].recordingFileName);
  819. }
  820. }
  821. });
  822. $scope.download = function (contentId, filename) {
  823. $http({
  824. url: "http://" + $scope.datasurl,
  825. method: 'GET',
  826. headers: {
  827. 'Content-type': 'application/octet-stream',
  828. },
  829. responseType: 'arraybuffer'
  830. }).success(function (data, status, headers, config) {
  831. var file = new Blob([data], {
  832. type: 'application/octet-stream'
  833. });
  834. //trick to download store a file having its URL
  835. var fileURL = URL.createObjectURL(file);
  836. var a = document.createElement('a');
  837. a.href = fileURL;
  838. a.target = '_blank';
  839. a.download = filename;
  840. document.body.appendChild(a);
  841. a.click();
  842. }).error(function (data, status, headers, config) {
  843. // console.log(data);
  844. });
  845. }
  846. $scope.cancel = function () {
  847. $modalInstance.dismiss('cancel');
  848. };
  849. $modalInstance.close();
  850. },
  851. });
  852. modalInstance.result.then(function (result) {}, function (reason) {});
  853. };
  854. //列表排序
  855. $scope.gridOptions.onRegisterApi = function (gridApi) {
  856. $scope.gridApi = gridApi;
  857. var index = 0;
  858. var oldheader = {};
  859. gridApi.grid.sortColumn = function (gridApi) {
  860. if (oldheader.field) {
  861. if (oldheader.field == gridApi.field) {
  862. } else {
  863. index = 0;
  864. }
  865. }
  866. index++;
  867. oldheader = gridApi;
  868. var fildata = $scope.memoryfilterData;
  869. if (index % 3 == 0) {
  870. delete $scope.memoryfilterData.incident;
  871. fildata = $scope.memoryfilterData;
  872. } else if (index % 3 == 1) {
  873. if (fildata.incident) {
  874. if (gridApi.field == "acceptDate") {
  875. angular.extend(fildata.incident, {
  876. "sort": gridApi.field
  877. });
  878. } else {
  879. angular.extend(fildata.incident, {
  880. "sort": gridApi.field + " desc , _incident.acceptDate"
  881. });
  882. }
  883. } else {
  884. if (gridApi.field == "acceptDate") {
  885. angular.extend(fildata, {
  886. 'incident': {
  887. "sort": gridApi.field
  888. }
  889. });
  890. } else {
  891. angular.extend(fildata, {
  892. 'incident': {
  893. "sort": gridApi.field + " desc , _incident.acceptDate"
  894. }
  895. });
  896. }
  897. }
  898. } else if (index % 3 == 2) {
  899. if (fildata.incident) {
  900. if (gridApi.field == "acceptDate") {
  901. angular.extend(fildata.incident, {
  902. "sort": gridApi.field,
  903. "order": "asc"
  904. });
  905. } else {
  906. angular.extend(fildata.incident, {
  907. "sort": gridApi.field + " asc , _incident.acceptDate"
  908. });
  909. }
  910. } else {
  911. if (gridApi.field == "acceptDate") {
  912. angular.extend(fildata, {
  913. 'incident': {
  914. "sort": gridApi.field,
  915. "order": "asc"
  916. }
  917. });
  918. } else {
  919. angular.extend(fildata.incident, {
  920. "sort": gridApi.field + " asc , _incident.acceptDate"
  921. });
  922. }
  923. }
  924. }
  925. fildata.assignee = loginUser.id;
  926. $scope.refreshData('expand-right', fildata);
  927. }
  928. $scope.jry_idx = 0;
  929. $scope.jry_sum = 10;
  930. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  931. var filtersData = $scope.memoryfilterData;
  932. filtersData.idx = newPage - 1;
  933. $scope.jry_idx = newPage - 1;
  934. filtersData.sum = pageSize;
  935. $scope.jry_sum = pageSize;
  936. if (JSON.parse(sessionStorage.getItem("searchincident")).idx != filtersData.idx || JSON.parse(sessionStorage.getItem("searchincident")).sum != filtersData.sum) {
  937. filtersData.assignee = loginUser.id;
  938. $scope.refreshData('expand-right', filtersData);
  939. }
  940. });
  941. $scope.Change = function (upTypes) {
  942. if (angular.isDefined($scope.selected.items)) {
  943. if (angular.isDefined(upTypes) && upTypes == 'upincident') {
  944. var data = {
  945. cancelUrl: 'app.incident.list',
  946. model: {
  947. problem: {
  948. title: $scope.selected.items.title,
  949. des: $scope.selected.items.description,
  950. proposePerson: $scope.selected.items.handlerUser,
  951. source: {
  952. id: 1,
  953. code: 1,
  954. name: ' 事件 '
  955. },
  956. incident: $scope.selected.items
  957. }
  958. }
  959. }
  960. $state.go('app.problem.incident', {
  961. pdKey: 'incident',
  962. dataId: $scope.selected.items.id,
  963. processInstanceId: $scope.selected.items.processInstanceId,
  964. 'model': JSON.stringify(data)
  965. });
  966. } else if (angular.isDefined(upTypes) && upTypes == 'upchange') {
  967. var data = {
  968. cancelUrl: 'app.incident.list',
  969. model: {
  970. change: {
  971. title: $scope.selected.items.title,
  972. description: $scope.selected.items.description,
  973. requestingPerson: $scope.selected.items.handlerUser,
  974. source: {
  975. id: 1,
  976. code: 1,
  977. name: ' 事件 '
  978. },
  979. incident: $scope.selected.items
  980. }
  981. }
  982. }
  983. // var data={cancelUrl:'app.incident.list'}
  984. $state.go('app.change.incident', {
  985. pdKey: 'incident',
  986. dataId: $scope.selected.items.id,
  987. processInstanceId: $scope.selected.items.processInstanceId,
  988. 'model': JSON.stringify(data)
  989. });
  990. }
  991. }
  992. }
  993. $scope.selected = {
  994. items: []
  995. }
  996. gridApi.core.on.filterChanged($scope, function () {
  997. var grid = this.grid;
  998. if ($rootScope.user.group) {
  999. var filtersData = {
  1000. "assignee": loginUser.id,
  1001. "candidateGroups": loginuserGroup,
  1002. idx: 0,
  1003. sum: mun
  1004. };
  1005. } else {
  1006. var filtersData = {
  1007. "assignee": loginUser.id,
  1008. idx: 0,
  1009. sum: mun
  1010. };
  1011. }
  1012. angular.forEach(grid.columns, function (item) {
  1013. if (item.enableFiltering) {
  1014. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  1015. filtersData = $scope.memoryfilterData
  1016. if (angular.isUndefined(filtersData['incident'])) {
  1017. filtersData['incident'] = {};
  1018. }
  1019. if (item.field == 'department.dept') {
  1020. filtersData['incident']['department'] = {};
  1021. filtersData.incident.department['department'] = item.filters[0].term;
  1022. } else if (item.field == 'handlingPersonnelUser.name') {
  1023. filtersData['incident']['handlingPersonnelUser'] = {};
  1024. filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
  1025. } else if (item.field == 'requester.account') {
  1026. filtersData['incident']['requester'] = {};
  1027. filtersData.incident.requester['account'] = item.filters[0].term;
  1028. } else if (item.field == 'acceptUser.name') {
  1029. filtersData['incident']['acceptUser'] = {};
  1030. filtersData.incident.acceptUser['name'] = item.filters[0].term;
  1031. } else {
  1032. filtersData['incident'][item.field] = item.filters[0].term;
  1033. }
  1034. }
  1035. }
  1036. });
  1037. filtersData.idx = 0;
  1038. filtersData.assignee = loginUser.id;
  1039. $scope.memoryfilterData = filtersData;
  1040. $scope.refreshData('expand-right', filtersData);
  1041. });
  1042. };
  1043. //编辑
  1044. $scope.selectRowFunction = function (data) {
  1045. $state.go('app.incident.editor', {
  1046. taskId: data.taskId,
  1047. processInstanceId: data.processInstanceId,
  1048. dataId: data.id,
  1049. });
  1050. };
  1051. //修改
  1052. $scope.changeClick = function (data) {
  1053. $state.go('app.incident.detail', {
  1054. formKey: 'incident_change',
  1055. pdKey: 'incident',
  1056. dataId: data.id,
  1057. taskId: data.taskId,
  1058. processInstanceId: data.processInstanceId
  1059. });
  1060. };
  1061. //回访
  1062. $scope.visit = function (data) {
  1063. $state.go('app.incident.detail', {
  1064. formKey: 'incident_visit',
  1065. pdKey: 'incident',
  1066. dataId: data.id,
  1067. taskId: data.taskId,
  1068. processInstanceId: data.processInstanceId
  1069. });
  1070. };
  1071. //导出
  1072. $scope.export = function () {
  1073. console.log($scope.memoryfilterData)
  1074. var filadata = angular.copy($scope.memoryfilterData);
  1075. filadata.sum = 10000;
  1076. console.log($scope.filadata)
  1077. $http({
  1078. url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
  1079. method: 'POST',
  1080. data: JSON.stringify(filadata),
  1081. headers: {
  1082. 'Accept': '*/*'
  1083. },
  1084. responseType: 'arraybuffer'
  1085. }).success(function (data, status, headers, config) {
  1086. var file = new Blob([data], {
  1087. type: 'application/vnd.ms-excel'
  1088. });
  1089. //trick to download store a file having its URL
  1090. var fileURL = URL.createObjectURL(file);
  1091. var a = document.createElement('a');
  1092. a.href = fileURL;
  1093. a.target = '_blank';
  1094. a.download = '事件列表.xls';
  1095. document.body.appendChild(a);
  1096. a.click();
  1097. }).error(function (data, status, headers, config) {
  1098. // $scope.ldloading.zoom_in = false;
  1099. console.log(data);
  1100. });
  1101. }
  1102. //事件提取
  1103. $scope.acceptTaskAction = function (model) {
  1104. var modalInstance = $modal.open({
  1105. templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
  1106. controller: function ($scope, $modalInstance, APIService, modelData, currentUserId, Alert) {
  1107. var receiveTask = function (receive_code, modelData) {
  1108. var data = {
  1109. 'receive_code': receive_code
  1110. };
  1111. if (modelData) {
  1112. return {
  1113. taskId: modelData.taskId,
  1114. data: data
  1115. };
  1116. } else {
  1117. return 'error';
  1118. }
  1119. };
  1120. $scope.title = "提示";
  1121. $scope.connect = "确认接单?";
  1122. $scope.ok = function () {
  1123. $rootScope.isMask = true;
  1124. //接收任务//请求重新指派
  1125. var data = receiveTask($scope.receive_code, modelData);
  1126. APIService.claimAndCompletedTask(data.taskId, {
  1127. userId: currentUserId,
  1128. receive_code: "handler"
  1129. }).then(function (response) {
  1130. $rootScope.isMask = false;
  1131. if (response.status == 200) {
  1132. Alert.swal({
  1133. title: "操作成功!",
  1134. confirmButtonColor: "#007AFF",
  1135. type: "success"
  1136. });
  1137. $modalInstance.close('success');
  1138. } else if (response.status == 500) {
  1139. Alert.swal({
  1140. title: "操作失败",
  1141. text: "该事件已被提取,请刷新页面!",
  1142. type: "error"
  1143. });
  1144. $modalInstance.close('success');
  1145. } else {
  1146. Alert.swal({
  1147. title: "操作失败",
  1148. text: "操作失败, 请稍后再试!",
  1149. type: "error"
  1150. });
  1151. }
  1152. });
  1153. }
  1154. $scope.cancel = function () {
  1155. $modalInstance.dismiss('cancel');
  1156. }
  1157. },
  1158. size: 'sm',
  1159. resolve: {
  1160. APIService: function () {
  1161. return api_bpm_domain;
  1162. },
  1163. modelData: function () {
  1164. return model;
  1165. },
  1166. currentUserId: function () {
  1167. return loginUser.id;
  1168. },
  1169. Alert: function () {
  1170. return SweetAlert;
  1171. }
  1172. }
  1173. });
  1174. modalInstance.result.then(function (selectedItem) {
  1175. if (selectedItem == 'success') {
  1176. defaultFilterData.assignee = loginUser.id;
  1177. $scope.refreshData('expand-right', defaultFilterData);
  1178. }
  1179. });
  1180. }
  1181. // 指派弹窗
  1182. $scope.toAssign = function (model) {
  1183. console.log(model)
  1184. var modalInstance = $modal.open({
  1185. templateUrl: 'assets/views/incident/tpl/toAssign.tpl.html',
  1186. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  1187. console.log(model,loginUser);
  1188. //获取组下面的用户
  1189. $scope.getUsers = function(groupId){
  1190. $scope.user = [];
  1191. var postData = {};
  1192. if(groupId){
  1193. postData = {
  1194. "idx": 0,
  1195. "sum": 100,
  1196. user: {
  1197. groupdata:{id:groupId},
  1198. roledata: { rolecode: "first-line support" },
  1199. roledata2: { rolecode: "second-line support" },
  1200. selectType: "1",
  1201. selectDetails:1,
  1202. simple: true,
  1203. }
  1204. }
  1205. }else{
  1206. postData = {
  1207. "idx": 0,
  1208. "sum": 100,
  1209. user: {
  1210. roledata: { rolecode: "first-line support" },
  1211. roledata2: { rolecode: "second-line support" },
  1212. selectType: "1",
  1213. selectDetails:1,
  1214. simple: true,
  1215. }
  1216. }
  1217. }
  1218. api_user_data.fetchDataList('user', postData).then(function (data) {
  1219. $scope.user = data.list;
  1220. })
  1221. }
  1222. $scope.assign = {
  1223. branch:undefined,
  1224. duty:undefined,
  1225. user:undefined,
  1226. group:undefined,
  1227. isRadioUser: 0,
  1228. }
  1229. $scope.hospitalList = [];
  1230. $scope.dutyDeptList = [];
  1231. $scope.user = [];
  1232. $scope.group = [];
  1233. $scope.isShowRadioUser = false;
  1234. // if(model.state.id == 1544){
  1235. // $scope.assign.isRadioUser = 1;
  1236. // $scope.isShowRadioUser = false;
  1237. // }else{
  1238. // $scope.assign.isRadioUser = 0;
  1239. // $scope.isShowRadioUser = true;
  1240. // }
  1241. // 修改是否指派到人
  1242. $scope.changeRadioUser = function(){
  1243. $scope.assign.user = undefined;
  1244. }
  1245. // 获取院区
  1246. $scope.getHospitals = function(){
  1247. //跨科室转派
  1248. api_user_data.fetchDataList('branch', {
  1249. "idx": 0,
  1250. "sum": 100
  1251. }).then(function (data) {
  1252. if(data.status == 200){
  1253. $scope.hospitalList = data.list;
  1254. if($scope.assign.duty){
  1255. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $scope.assign.duty.branch);
  1256. }else{
  1257. if($rootScope.user.duty){
  1258. // 当前的所属责任科室
  1259. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  1260. $scope.assign.duty = $rootScope.user.duty;
  1261. $scope.changeDuty();
  1262. }else if($rootScope.user.branch){
  1263. // 当前的所属院区
  1264. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  1265. }
  1266. }
  1267. }else{
  1268. SweetAlert.swal({
  1269. title: "系统错误!",
  1270. text: "请刷新重试!",
  1271. type: "error"
  1272. });
  1273. }
  1274. })
  1275. }
  1276. $scope.getHospitals();
  1277. // 修改院区
  1278. $scope.changeBranch = function(keyword){
  1279. if(keyword === undefined){
  1280. $scope.assign.duty = undefined;
  1281. $scope.dutyDeptList = [];
  1282. $scope.assign.group = undefined;
  1283. $scope.group = [];
  1284. $scope.assign.user = undefined;
  1285. $scope.user = [];
  1286. }
  1287. if(!$scope.assign.branch){
  1288. $scope.dutyDeptList = [];
  1289. return;
  1290. }
  1291. api_user_data.fetchDataList('dutyDepartment', {
  1292. "idx": 0,
  1293. "sum": 100,
  1294. "dutyDepartment":{
  1295. branch:$scope.assign.branch.id,
  1296. dept:keyword,
  1297. selectType: "pinyin_qs"
  1298. }
  1299. }).then(function (data) {
  1300. if(data.status == 200){
  1301. $scope.dutyDeptList = data.list;
  1302. }else{
  1303. SweetAlert.swal({
  1304. title: "系统错误!",
  1305. text: "请刷新重试!",
  1306. type: "error"
  1307. });
  1308. }
  1309. })
  1310. }
  1311. // 修改责任科室
  1312. $scope.changeDuty = function(keyword){
  1313. if(keyword === undefined){
  1314. $scope.assign.user = undefined;
  1315. $scope.user = [];
  1316. $scope.assign.group = undefined;
  1317. $scope.group = [];
  1318. }
  1319. api_user_data.fetchDataList('group', {
  1320. "idx": 0,
  1321. "sum": 9999,
  1322. "group":{
  1323. duty:$scope.assign.duty,
  1324. selectType: "nouser"
  1325. }
  1326. }).then(function (data) {
  1327. if(data.status == 200){
  1328. $scope.group = data.list;
  1329. }else{
  1330. SweetAlert.swal({
  1331. title: "系统错误!",
  1332. text: "请刷新重试!",
  1333. type: "error"
  1334. });
  1335. }
  1336. })
  1337. }
  1338. $scope.changeGroup = function(item){
  1339. // $scope.assign.group = item.id;
  1340. $scope.assign.user = undefined;
  1341. $scope.user = [];
  1342. $scope.getUsers(item.id)
  1343. }
  1344. $scope.ok = function () {
  1345. if ($scope.assign.isRadioUser == 1 && !$scope.assign.user){
  1346. Alert.swal({
  1347. title: "操作失败",
  1348. text: "请选择转派对象信息!",
  1349. type: "error"
  1350. });
  1351. return;
  1352. }
  1353. if ($scope.assign.isRadioUser == 0 && !$scope.assign.group){
  1354. Alert.swal({
  1355. title: "操作失败",
  1356. text: "请选择工作组!",
  1357. type: "error"
  1358. });
  1359. return;
  1360. }
  1361. var postData = {};
  1362. if($scope.assign.user && $scope.assign.user.id){
  1363. // 派人
  1364. // 接单
  1365. if(model.state.value == 'pending'){
  1366. postData = {
  1367. type: 'receiveAssginee',
  1368. userId: $scope.assign.user.id,
  1369. taskId: model.taskId,
  1370. incidentId: model.id,
  1371. logType: 'assign',
  1372. }
  1373. }
  1374. // 处理中
  1375. if(model.state.value == 'handler'){
  1376. postData = {
  1377. type: 'handlerAssginee',
  1378. userId: $scope.assign.user.id,
  1379. taskId: model.taskId,
  1380. incidentId: model.id,
  1381. logType: 'assign',
  1382. }
  1383. }
  1384. } else if($scope.assign.group && $scope.assign.group.id){
  1385. // 派组
  1386. // 接单,派组
  1387. if(model.state.value == 'pending'){
  1388. postData = {
  1389. type: 'receiveGroup',
  1390. groupId: $scope.assign.group.id,
  1391. taskId: model.taskId,
  1392. activityId: 'usertask5',
  1393. executionId: model.processInstanceId,
  1394. incidentId: model.id,
  1395. logType: 'assign',
  1396. }
  1397. }
  1398. // 处理中
  1399. if(model.state.value == 'handler'){
  1400. postData = {
  1401. type: 'handlerGroup',
  1402. groupId: $scope.assign.group.id,
  1403. taskId: model.taskId,
  1404. activityId: 'usertask5',
  1405. executionId: model.processInstanceId,
  1406. incidentId: model.id,
  1407. logType: 'assign',
  1408. }
  1409. }
  1410. }
  1411. // if($scope.assign.isRadioUser == 1){
  1412. // postData = {
  1413. // assginee:$scope.assign.user.id,
  1414. // handlerIncidentId: model.state.value === 'handler' ? model.id : undefined,
  1415. // incId: model.assignee ? model.id : undefined,
  1416. // incidentId: model.assignee ? undefined : model.id,
  1417. // taskType: model.state.value == 'handler' ? 'handlerform' : (model.state.value == 'pending' ? 'receiveform' : undefined)
  1418. // };
  1419. // }else{
  1420. // postData = {
  1421. // group:$scope.assign.group.id,
  1422. // taskType: model.state.value == 'handler' ? 'handlerform' : (model.state.value == 'pending' ? 'receiveform' : undefined)
  1423. // };
  1424. // }
  1425. $rootScope.isMask = true;
  1426. api_bpm_domain.delegateTask2(postData).then(function (response) {
  1427. console.log(response)
  1428. $rootScope.isMask = false;
  1429. if (response.status == 200) {
  1430. Alert.swal({
  1431. title: "操作成功!",
  1432. confirmButtonColor: "#007AFF",
  1433. type: "success"
  1434. });
  1435. $modalInstance.close('success');
  1436. } else {
  1437. Alert.swal({
  1438. title: "操作失败",
  1439. text: "操作失败, 请稍后再试!",
  1440. type: "error"
  1441. });
  1442. }
  1443. });
  1444. }
  1445. $scope.cancel = function () {
  1446. $modalInstance.dismiss('cancel');
  1447. }
  1448. },
  1449. size: 'sm',
  1450. resolve: {
  1451. api_bpm: function () {
  1452. return api_bpm;
  1453. },
  1454. modelData: function () {
  1455. return model;
  1456. },
  1457. currentUserId: function () {
  1458. return loginUser.id;
  1459. },
  1460. Alert: function () {
  1461. return SweetAlert;
  1462. },
  1463. api_user_data: function () {
  1464. return api_user_data;
  1465. }
  1466. }
  1467. });
  1468. modalInstance.result.then(function (selectedItem) {
  1469. if (selectedItem == 'success') {
  1470. defaultFilterData.assignee = loginUser.id;
  1471. $scope.refreshData('expand-right', defaultFilterData);
  1472. }
  1473. });
  1474. }
  1475. // 转派弹窗
  1476. $scope.toTransfer = function (model) {
  1477. console.log(model)
  1478. var modalInstance = $modal.open({
  1479. templateUrl: 'assets/views/incident/tpl/toTransfer.tpl.html',
  1480. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  1481. console.log(model,loginUser);
  1482. $scope.assign = {
  1483. duty:model.duty,
  1484. user:undefined,
  1485. group:undefined,
  1486. isRadioGroup: 0,
  1487. }
  1488. $scope.user = [];
  1489. $scope.group = [];
  1490. //获取责任科室下面的用户
  1491. $scope.getUsers = function(){
  1492. $scope.user = [];
  1493. var postData = {
  1494. "idx": 0,
  1495. "sum": 9999,
  1496. user: {
  1497. currentDuty: $scope.assign.duty.id,
  1498. roledata: { rolecode: "first-line support" },
  1499. roledata2: { rolecode: "second-line support" },
  1500. selectType: "1",
  1501. selectDetails:1,
  1502. simple: true,
  1503. }
  1504. }
  1505. api_user_data.fetchDataList('user', postData).then(function (data) {
  1506. $scope.user = data.list;
  1507. })
  1508. }
  1509. $scope.getUsers();
  1510. //获取责任科室下面的组
  1511. $scope.getGroups = function(){
  1512. $scope.group = [];
  1513. var postData = {
  1514. "idx": 0,
  1515. "sum": 9999,
  1516. group: {
  1517. duty: $scope.assign.duty,
  1518. selectType: "nouser",
  1519. }
  1520. }
  1521. api_user_data.fetchDataList('group', postData).then(function (data) {
  1522. $scope.group = data.list;
  1523. })
  1524. }
  1525. $scope.getGroups();
  1526. // 修改是否转派到组
  1527. $scope.changeRadioGroup = function(){
  1528. $scope.assign.group = undefined;
  1529. $scope.assign.user = undefined;
  1530. }
  1531. $scope.ok = function () {
  1532. if ($scope.assign.isRadioGroup == 0 && !$scope.assign.user){
  1533. Alert.swal({
  1534. title: "操作失败",
  1535. text: "请选择转派对象信息!",
  1536. type: "error"
  1537. });
  1538. return;
  1539. }
  1540. if ($scope.assign.isRadioGroup == 1 && !$scope.assign.group){
  1541. Alert.swal({
  1542. title: "操作失败",
  1543. text: "请选择工作组!",
  1544. type: "error"
  1545. });
  1546. return;
  1547. }
  1548. var postData = {};
  1549. if($scope.assign.user && $scope.assign.user.id){
  1550. // 派人
  1551. // 接单
  1552. if(model.state.value == 'pending'){
  1553. postData = {
  1554. type: 'receiveAssginee',
  1555. userId: $scope.assign.user.id,
  1556. taskId: model.taskId,
  1557. incidentId: model.id,
  1558. logType: 'redeploy',
  1559. }
  1560. }
  1561. // 处理中
  1562. if(model.state.value == 'handler'){
  1563. postData = {
  1564. type: 'handlerAssginee',
  1565. userId: $scope.assign.user.id,
  1566. taskId: model.taskId,
  1567. incidentId: model.id,
  1568. logType: 'redeploy',
  1569. }
  1570. }
  1571. } else if($scope.assign.group && $scope.assign.group.id){
  1572. // 派组
  1573. // 接单,派组
  1574. if(model.state.value == 'pending'){
  1575. postData = {
  1576. type: 'receiveGroup',
  1577. groupId: $scope.assign.group.id,
  1578. taskId: model.taskId,
  1579. activityId: 'usertask5',
  1580. executionId: model.processInstanceId,
  1581. incidentId: model.id,
  1582. logType: 'redeploy',
  1583. }
  1584. }
  1585. // 处理中
  1586. if(model.state.value == 'handler'){
  1587. postData = {
  1588. type: 'handlerGroup',
  1589. groupId: $scope.assign.group.id,
  1590. taskId: model.taskId,
  1591. activityId: 'usertask5',
  1592. executionId: model.processInstanceId,
  1593. incidentId: model.id,
  1594. logType: 'redeploy',
  1595. }
  1596. }
  1597. }
  1598. $rootScope.isMask = true;
  1599. api_bpm_domain.delegateTask2(postData).then(function (response) {
  1600. console.log(response)
  1601. $rootScope.isMask = false;
  1602. if (response.status == 200) {
  1603. Alert.swal({
  1604. title: "操作成功!",
  1605. confirmButtonColor: "#007AFF",
  1606. type: "success"
  1607. });
  1608. $modalInstance.close('success');
  1609. } else {
  1610. Alert.swal({
  1611. title: "操作失败",
  1612. text: "操作失败, 请稍后再试!",
  1613. type: "error"
  1614. });
  1615. }
  1616. });
  1617. }
  1618. $scope.cancel = function () {
  1619. $modalInstance.dismiss('cancel');
  1620. }
  1621. },
  1622. size: 'sm',
  1623. resolve: {
  1624. api_bpm: function () {
  1625. return api_bpm;
  1626. },
  1627. modelData: function () {
  1628. return model;
  1629. },
  1630. currentUserId: function () {
  1631. return loginUser.id;
  1632. },
  1633. Alert: function () {
  1634. return SweetAlert;
  1635. },
  1636. api_user_data: function () {
  1637. return api_user_data;
  1638. }
  1639. }
  1640. });
  1641. modalInstance.result.then(function (selectedItem) {
  1642. if (selectedItem == 'success') {
  1643. defaultFilterData.assignee = loginUser.id;
  1644. $scope.refreshData('expand-right', defaultFilterData);
  1645. }
  1646. });
  1647. }
  1648. // 删除事件
  1649. $scope.delSj = function(model){
  1650. console.log(model);
  1651. SweetAlert.swal({
  1652. title: "确认删除?",
  1653. text: "删除的数据不可恢复,请确认继续操作!",
  1654. type: "warning",
  1655. showCancelButton: true,
  1656. confirmButtonColor: "#DD6B55",
  1657. confirmButtonText: "继续删除",
  1658. cancelButtonText: "取消操作",
  1659. closeOnConfirm: false,
  1660. closeOnCancel: false
  1661. }, function (isConfirm) {
  1662. if (isConfirm) {
  1663. api_bpm_schedule.del(model.id).then(function (response) {
  1664. if (response.status == 200) {
  1665. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  1666. $scope.refreshData('expand-right', JSON.parse(sessionStorage.getItem("searchincident")));
  1667. } else {
  1668. SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
  1669. }
  1670. });
  1671. } else {
  1672. SweetAlert.swal("操作取消", "数据安全", "error");
  1673. }
  1674. });
  1675. }
  1676. // 新增维修记录弹窗
  1677. $scope.toHandlerLog = function (model) {
  1678. console.log(model)
  1679. var modalInstance = $modal.open({
  1680. templateUrl: 'assets/views/incident/tpl/toHandlerLog.tpl.html',
  1681. controller: function ($scope, $modalInstance, api_bpm_domain,api_bpm_data, modelData, currentUserId, Alert, api_user_data,api_statistic) {
  1682. console.log(model,loginUser);
  1683. $scope.f = {
  1684. maintenanceMode: '',
  1685. estimatedNumberOfDays: ''
  1686. }
  1687. $scope.handlerLog = '';
  1688. $scope.user = [];
  1689. $scope.logs = [];
  1690. $scope.modes = [];
  1691. $scope.getModes=function(){
  1692. var data={
  1693. "idx":0,
  1694. "sum":999,
  1695. dictionary:{key:'repair_type'}
  1696. }
  1697. api_statistic.tableData(data,"dictionary").then(function(res){
  1698. $scope.modes=res.list
  1699. })
  1700. }
  1701. $scope.getModes();
  1702. $scope.getLogs=function(){
  1703. var data={
  1704. "idx":0,
  1705. "sum":999,
  1706. dictionary:{key:'processingLog'}
  1707. }
  1708. api_statistic.tableData(data,"dictionary").then(function(res){
  1709. $scope.logs=res.list
  1710. })
  1711. }
  1712. $scope.getLogs();
  1713. $scope.copyTo = function(value){
  1714. $scope.handlerLog += value;
  1715. }
  1716. $scope.ok = function () {
  1717. if (!$scope.f.maintenanceMode){
  1718. Alert.swal({
  1719. title: "操作失败",
  1720. text: "请选择维修方式!",
  1721. type: "error"
  1722. });
  1723. return;
  1724. }
  1725. if (!$scope.f.estimatedNumberOfDays){
  1726. Alert.swal({
  1727. title: "操作失败",
  1728. text: "请选择预估天数!",
  1729. type: "error"
  1730. });
  1731. return;
  1732. }
  1733. if (!$scope.handlerLog.trim()){
  1734. Alert.swal({
  1735. title: "操作失败",
  1736. text: "请填写备注!",
  1737. type: "error"
  1738. });
  1739. return;
  1740. }
  1741. $rootScope.isMask = true;
  1742. api_bpm_data.addData('operationLog',{
  1743. operationLog:{
  1744. opType:'handlerLog',
  1745. opValue:$scope.handlerLog,
  1746. extra1:model.id,
  1747. repairType: $scope.f.maintenanceMode,
  1748. expectedDay: $scope.f.estimatedNumberOfDays
  1749. }
  1750. }).then(function(response){
  1751. console.log(response)
  1752. $rootScope.isMask = false;
  1753. if (response.status == 200) {
  1754. Alert.swal({
  1755. title: "操作成功!",
  1756. confirmButtonColor: "#007AFF",
  1757. type: "success"
  1758. });
  1759. $modalInstance.close('success');
  1760. } else {
  1761. Alert.swal({
  1762. title: "操作失败",
  1763. text: "操作失败, 请稍后再试!",
  1764. type: "error"
  1765. });
  1766. }
  1767. });
  1768. }
  1769. $scope.cancel = function () {
  1770. $modalInstance.dismiss('cancel');
  1771. }
  1772. },
  1773. size: 'lg',
  1774. resolve: {
  1775. api_bpm: function () {
  1776. return api_bpm;
  1777. },
  1778. modelData: function () {
  1779. return model;
  1780. },
  1781. currentUserId: function () {
  1782. return loginUser.id;
  1783. },
  1784. Alert: function () {
  1785. return SweetAlert;
  1786. },
  1787. api_user_data: function () {
  1788. return api_user_data;
  1789. },
  1790. api_statistic: function () {
  1791. return api_statistic;
  1792. }
  1793. }
  1794. });
  1795. modalInstance.result.then(function (selectedItem) {
  1796. if (selectedItem == 'success') {
  1797. defaultFilterData.assignee = loginUser.id;
  1798. $scope.refreshData('expand-right', defaultFilterData);
  1799. }
  1800. });
  1801. }
  1802. // 设置责任科室
  1803. $scope.setDuty = function (model) {
  1804. console.log(model)
  1805. var modalInstance = $modal.open({
  1806. templateUrl: 'assets/views/incident/tpl/setDuty.tpl.html',
  1807. controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
  1808. console.log(model,loginUser);
  1809. $scope.assign = {
  1810. branch:undefined,
  1811. duty:undefined,
  1812. }
  1813. $scope.hospitalList = [];
  1814. $scope.dutyDeptList = [];
  1815. // 获取院区
  1816. $scope.getHospitals = function(){
  1817. //跨科室转派
  1818. api_user_data.fetchDataList('branch', {
  1819. "idx": 0,
  1820. "sum": 100
  1821. }).then(function (data) {
  1822. if(data.status == 200){
  1823. $scope.hospitalList = data.list;
  1824. if($scope.assign.duty){
  1825. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $scope.assign.duty.branch);
  1826. }else{
  1827. if($rootScope.user.duty){
  1828. // 当前的所属责任科室
  1829. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  1830. $scope.assign.duty = $rootScope.user.duty;
  1831. $scope.changeDuty();
  1832. }else if($rootScope.user.branch){
  1833. // 当前的所属院区
  1834. $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  1835. }
  1836. }
  1837. }else{
  1838. SweetAlert.swal({
  1839. title: "系统错误!",
  1840. text: "请刷新重试!",
  1841. type: "error"
  1842. });
  1843. }
  1844. })
  1845. }
  1846. $scope.getHospitals();
  1847. // 修改院区
  1848. $scope.changeBranch = function(keyword){
  1849. if(keyword === undefined){
  1850. $scope.assign.duty = undefined;
  1851. $scope.dutyDeptList = [];
  1852. }
  1853. if(!$scope.assign.branch){
  1854. $scope.dutyDeptList = [];
  1855. return;
  1856. }
  1857. api_user_data.fetchDataList('dutyDepartment', {
  1858. "idx": 0,
  1859. "sum": 100,
  1860. "dutyDepartment":{
  1861. branch:$scope.assign.branch.id,
  1862. dept:keyword,
  1863. selectType: "pinyin_qs"
  1864. }
  1865. }).then(function (data) {
  1866. if(data.status == 200){
  1867. $scope.dutyDeptList = data.list;
  1868. }else{
  1869. SweetAlert.swal({
  1870. title: "系统错误!",
  1871. text: "请刷新重试!",
  1872. type: "error"
  1873. });
  1874. }
  1875. })
  1876. }
  1877. $scope.ok = function () {
  1878. if (!$scope.assign.duty){
  1879. Alert.swal({
  1880. title: "操作失败",
  1881. text: "请选择责任科室!",
  1882. type: "error"
  1883. });
  1884. return;
  1885. }
  1886. $rootScope.isMask = true;
  1887. api_bpm_domain.changeIncidentDuty({orderId: model.id, dutyId: $scope.assign.duty.id}).then(function (response) {
  1888. console.log(response)
  1889. $rootScope.isMask = false;
  1890. if (response.status == 200) {
  1891. Alert.swal({
  1892. title: "操作成功!",
  1893. confirmButtonColor: "#007AFF",
  1894. type: "success"
  1895. });
  1896. $modalInstance.close('success');
  1897. } else {
  1898. Alert.swal({
  1899. title: "操作失败",
  1900. text: "操作失败, 请稍后再试!",
  1901. type: "error"
  1902. });
  1903. }
  1904. });
  1905. }
  1906. $scope.cancel = function () {
  1907. $modalInstance.dismiss('cancel');
  1908. }
  1909. },
  1910. size: 'sm',
  1911. resolve: {
  1912. api_bpm: function () {
  1913. return api_bpm;
  1914. },
  1915. modelData: function () {
  1916. return model;
  1917. },
  1918. currentUserId: function () {
  1919. return loginUser.id;
  1920. },
  1921. Alert: function () {
  1922. return SweetAlert;
  1923. },
  1924. api_user_data: function () {
  1925. return api_user_data;
  1926. }
  1927. }
  1928. });
  1929. modalInstance.result.then(function (selectedItem) {
  1930. if (selectedItem == 'success') {
  1931. defaultFilterData.assignee = loginUser.id;
  1932. $scope.refreshData('expand-right', defaultFilterData);
  1933. }
  1934. });
  1935. }
  1936. if ($stateParams.model) {
  1937. if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
  1938. $scope.searchType = JSON.parse($stateParams.model).searchType;
  1939. } else {
  1940. $scope.searchType = "todo";
  1941. }
  1942. } else {
  1943. $scope.searchType = "todo";
  1944. }
  1945. if ($rootScope.user.group) {
  1946. var defaultFilterData = {
  1947. "assignee": loginUser.id,
  1948. "candidateGroups": loginuserGroup,
  1949. "searchType": "todo",
  1950. "idx": 0,
  1951. "sum": mun
  1952. };
  1953. } else {
  1954. var defaultFilterData = {
  1955. "assignee": $rootScope.user.id,
  1956. "searchType": "todo",
  1957. "idx": 0,
  1958. "sum": mun
  1959. };
  1960. }
  1961. if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
  1962. defaultFilterData['searchType'] = $rootScope.search.incident;
  1963. $scope.searchType = $rootScope.search.incident;
  1964. }
  1965. $scope.ldloading = {};
  1966. //事件类型筛选
  1967. console.log($state);
  1968. if($state.params.tab){
  1969. $scope.searchstate = $state.params.tab;
  1970. }else{
  1971. $scope.searchstate = 'todo';
  1972. }
  1973. $scope.onChange = function (searchType) {
  1974. if(searchType === 'all_del'){
  1975. var obj = $scope.state.find(function(v){return v.id == 1708});
  1976. $scope.othcode = {state:obj};
  1977. $scope.isDisabledState = true;
  1978. }else{
  1979. $scope.isDisabledState = false;
  1980. }
  1981. $scope.searchstate = searchType;
  1982. $scope.chiceIncident($scope.searchkeys,$scope.othcode.state);
  1983. }
  1984. // 是否逾期下拉框选择seimin
  1985. $scope.selectTypeChange = function(){
  1986. console.log($scope.searchkeys.selectType,66666);
  1987. if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
  1988. $scope.searchkeys.selectType = {id:'2',name:'是'};
  1989. }
  1990. var ids = $scope.searchkeys.selectType.id
  1991. if(defaultFilterData.incident){
  1992. defaultFilterData.incident.selectType = ids;//seimin
  1993. }else{
  1994. defaultFilterData.incident = {
  1995. selectType:ids
  1996. };
  1997. }
  1998. defaultFilterData.searchType = 'all';
  1999. console.log(defaultFilterData,2222)
  2000. $scope.onChange('all');
  2001. }
  2002. //获取列表数据
  2003. $scope.refreshData = function (style, filterData) {
  2004. console.log(filterData,9090)
  2005. if (filterData && filterData.incident && filterData.incident.area) {
  2006. filterData.incident.place = {
  2007. id: filterData.incident.place ? filterData.incident.place.id : '',
  2008. area: filterData.incident.area
  2009. }
  2010. delete filterData.incident.area
  2011. }
  2012. $scope.ldloading[style.replace('-', '_')] = true;
  2013. if (angular.isUndefined(filterData)) {
  2014. if (sessionStorage.searchincident) {
  2015. filterData = JSON.parse(sessionStorage.getItem("searchincident"));
  2016. if ($scope.searchType) {
  2017. filterData.searchType = $scope.searchType;
  2018. }
  2019. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2020. if($state.params.tab){
  2021. $scope.searchstate = $state.params.tab;
  2022. filterData.searchType = $state.params.tab;
  2023. filterData.idx = 0;
  2024. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2025. sessionStorage.setItem('searchincident',JSON.stringify(filterData));
  2026. }else{
  2027. $scope.searchstate = filterData.searchType;
  2028. }
  2029. if($state.params.date == 'today'){
  2030. $scope.othcode = {};
  2031. $scope.searchkeys.acceptDate = new Date();
  2032. $scope.searchkeys.acceptDateEnd = new Date();
  2033. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  2034. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2035. }else{
  2036. $scope.searchkeys.acceptDate = null;
  2037. $scope.searchkeys.acceptDateEnd = null;
  2038. }
  2039. if($state.params.state){
  2040. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  2041. $scope.othcode = {state:obj};
  2042. filterData.incident = {statusId: $state.params.state};
  2043. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2044. }
  2045. if (filterData.incident && filterData.incident.category) {
  2046. delete filterData.incident.category
  2047. }
  2048. } else {
  2049. filterData = defaultFilterData;
  2050. if ($scope.searchType) {
  2051. filterData.searchType = $scope.searchType;
  2052. if (filterData.searchType == 'overDate') {
  2053. $scope.searchstate = 'overDate';
  2054. }
  2055. }
  2056. if($state.params.tab){
  2057. $scope.searchstate = $state.params.tab;
  2058. filterData.searchType = $state.params.tab;
  2059. filterData.idx = 0;
  2060. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2061. sessionStorage.setItem('searchincident',JSON.stringify(filterData));
  2062. }else{
  2063. $scope.searchstate = filterData.searchType;
  2064. }
  2065. if($state.params.date == 'today'){
  2066. $scope.othcode = {};
  2067. $scope.searchkeys.acceptDate = new Date();
  2068. $scope.searchkeys.acceptDateEnd = new Date();
  2069. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  2070. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2071. }else{
  2072. $scope.searchkeys.acceptDate = null;
  2073. $scope.searchkeys.acceptDateEnd = null;
  2074. }
  2075. if($state.params.state){
  2076. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  2077. $scope.othcode = {state:obj};
  2078. filterData.incident = {statusId: $state.params.state};
  2079. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2080. }
  2081. }
  2082. } else {
  2083. filterData.searchType = $scope.searchstate;
  2084. }
  2085. console.log(filterData,11111);
  2086. if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
  2087. $scope.searchkeys.selectType = {id:'2',name:'是'};
  2088. if(filterData.incident&&filterData.incident.selectType){
  2089. filterData.incident.selectType = '2';
  2090. }else{
  2091. filterData.incident = {
  2092. selectType : '2'
  2093. }
  2094. }
  2095. window.sessionStorage.removeItem('isGoyuqi');
  2096. }
  2097. $scope.myData = [];
  2098. sessionStorage['searchincident'] = angular.copy(JSON.stringify(filterData));
  2099. $scope.memoryfilterData = filterData;
  2100. $scope.gridOptions['sum'] = filterData.sum;
  2101. // 如果是全部,则根据权限查询
  2102. if(filterData.searchType == 'all'){
  2103. if(!filterData.incident){
  2104. filterData.incident = {};
  2105. }
  2106. if($rootScope.user.duty){
  2107. // 当前的所属责任科室
  2108. filterData.incident.duty = $rootScope.user.duty;
  2109. }else if($rootScope.user.branch){
  2110. // 当前的所属院区
  2111. filterData.incident.branch = $rootScope.user.branch.id;
  2112. }
  2113. }
  2114. if(filterData.searchType == 'all'){
  2115. //全部事件
  2116. api_user_data.fetchDataList('incident', filterData).then(function (data) {
  2117. if (data.list) {
  2118. var myData = Restangular.stripRestangular(data);
  2119. $scope.gridOptions['totalItems'] = myData.totalNum;
  2120. $scope.myData = myData.list;
  2121. for (var i = 0; i < $scope.myData.length; i++) {
  2122. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2123. }
  2124. } else {
  2125. SweetAlert.swal({
  2126. title: "系统错误",
  2127. text: "请稍后再试!",
  2128. type: "error"
  2129. });
  2130. }
  2131. $scope.ldloading[style.replace('-', '_')] = false;
  2132. }, function () {
  2133. $scope.ldloading[style.replace('-', '_')] = false;
  2134. });
  2135. }else if(filterData.searchType == 'done'){
  2136. //与我关联
  2137. api_flow.owns(filterData).then(function (data) {
  2138. if (data.data.data) {
  2139. var myData = Restangular.stripRestangular(data.data);
  2140. $scope.gridOptions['totalItems'] = myData.resultCount;
  2141. $scope.myData = myData.data;
  2142. for (var i = 0; i < $scope.myData.length; i++) {
  2143. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2144. }
  2145. } else {
  2146. SweetAlert.swal({
  2147. title: "系统错误",
  2148. text: "请稍后再试!",
  2149. type: "error"
  2150. });
  2151. }
  2152. $scope.ldloading[style.replace('-', '_')] = false;
  2153. }, function () {
  2154. $scope.ldloading[style.replace('-', '_')] = false;
  2155. });
  2156. }else{
  2157. // 非全部事件
  2158. api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
  2159. if (data.data) {
  2160. var myData = Restangular.stripRestangular(data);
  2161. $scope.gridOptions['totalItems'] = myData.resultCount;
  2162. $scope.myData = myData.data;
  2163. for (var i = 0; i < $scope.myData.length; i++) {
  2164. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2165. }
  2166. } else {
  2167. SweetAlert.swal({
  2168. title: "系统错误",
  2169. text: "请稍后再试!",
  2170. type: "error"
  2171. });
  2172. }
  2173. $scope.ldloading[style.replace('-', '_')] = false;
  2174. }, function () {
  2175. $scope.ldloading[style.replace('-', '_')] = false;
  2176. });
  2177. }
  2178. };
  2179. $scope.refreshData2 = function (style, filterData) {
  2180. $scope.ldloading[style.replace('-', '_')] = true;
  2181. if (angular.isUndefined(filterData)) {
  2182. if (sessionStorage.searchincident) {
  2183. filterData = JSON.parse(sessionStorage.getItem("searchincident"));
  2184. if ($scope.searchType) {
  2185. filterData.searchType = $scope.searchType;
  2186. }
  2187. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2188. if($state.params.tab){
  2189. $scope.searchstate = $state.params.tab;
  2190. filterData.searchType = $state.params.tab;
  2191. filterData.idx = 0;
  2192. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2193. sessionStorage.setItem('searchincident',JSON.stringify(filterData));
  2194. }else{
  2195. $scope.searchstate = filterData.searchType;
  2196. }
  2197. if($state.params.date == 'today'){
  2198. $scope.othcode = {};
  2199. $scope.searchkeys.acceptDate = new Date();
  2200. $scope.searchkeys.acceptDateEnd = new Date();
  2201. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  2202. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2203. }else{
  2204. $scope.searchkeys.acceptDate = null;
  2205. $scope.searchkeys.acceptDateEnd = null;
  2206. }
  2207. if($state.params.state){
  2208. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  2209. $scope.othcode = {state:obj};
  2210. filterData.incident = {statusId: $state.params.state};
  2211. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2212. }
  2213. if (filterData.incident && filterData.incident.category) {
  2214. delete filterData.incident.category
  2215. }
  2216. } else {
  2217. filterData = defaultFilterData;
  2218. if ($scope.searchType) {
  2219. filterData.searchType = $scope.searchType;
  2220. if (filterData.searchType == 'overDate') {
  2221. $scope.searchstate = 'overDate';
  2222. }
  2223. }
  2224. }
  2225. }else{
  2226. filterData.searchType = $scope.searchstate;
  2227. }
  2228. $scope.myData = [];
  2229. sessionStorage['searchincident'] = angular.copy(JSON.stringify(filterData));
  2230. $scope.memoryfilterData = filterData;
  2231. $scope.gridOptions['sum'] = filterData.sum;
  2232. // 如果是全部,则根据权限查询
  2233. if(filterData.searchType == 'all'){
  2234. if(!filterData.incident){
  2235. filterData.incident = {};
  2236. }
  2237. if($rootScope.user.duty){
  2238. // 当前的所属责任科室
  2239. filterData.incident.duty = $rootScope.user.duty;
  2240. }else if($rootScope.user.branch){
  2241. // 当前的所属院区
  2242. filterData.incident.branch = $rootScope.user.branch.id;
  2243. }
  2244. }
  2245. if(filterData.searchType == 'all'){
  2246. //全部事件
  2247. api_user_data.fetchDataList('incident', filterData).then(function (data) {
  2248. if (data.list) {
  2249. var myData = Restangular.stripRestangular(data);
  2250. $scope.gridOptions['totalItems'] = myData.totalNum;
  2251. $scope.myData = myData.list;
  2252. for (var i = 0; i < $scope.myData.length; i++) {
  2253. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2254. }
  2255. } else {
  2256. SweetAlert.swal({
  2257. title: "系统错误",
  2258. text: "请稍后再试!",
  2259. type: "error"
  2260. });
  2261. }
  2262. $scope.ldloading[style.replace('-', '_')] = false;
  2263. }, function () {
  2264. $scope.ldloading[style.replace('-', '_')] = false;
  2265. });
  2266. }else if(filterData.searchType == 'done'){
  2267. //与我关联
  2268. api_flow.owns(filterData).then(function (data) {
  2269. if (data.data.data) {
  2270. var myData = Restangular.stripRestangular(data.data);
  2271. $scope.gridOptions['totalItems'] = myData.resultCount;
  2272. $scope.myData = myData.data;
  2273. for (var i = 0; i < $scope.myData.length; i++) {
  2274. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2275. }
  2276. } else {
  2277. SweetAlert.swal({
  2278. title: "系统错误",
  2279. text: "请稍后再试!",
  2280. type: "error"
  2281. });
  2282. }
  2283. $scope.ldloading[style.replace('-', '_')] = false;
  2284. }, function () {
  2285. $scope.ldloading[style.replace('-', '_')] = false;
  2286. });
  2287. }else{
  2288. api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
  2289. if (data.data) {
  2290. var myData = Restangular.stripRestangular(data);
  2291. $scope.gridOptions['totalItems'] = myData.resultCount;
  2292. $scope.myData = myData.data;
  2293. for (var i = 0; i < $scope.myData.length; i++) {
  2294. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2295. }
  2296. } else {
  2297. SweetAlert.swal({
  2298. title: "系统错误",
  2299. text: "请稍后再试!",
  2300. type: "error"
  2301. });
  2302. }
  2303. $scope.ldloading[style.replace('-', '_')] = false;
  2304. }, function () {
  2305. $scope.ldloading[style.replace('-', '_')] = false;
  2306. });
  2307. }
  2308. };
  2309. // 进入页面时111
  2310. if(window.sessionStorage.getItem('searchincident')){
  2311. var varLin = JSON.parse(window.sessionStorage.getItem('searchincident'));
  2312. if(varLin.incident&&varLin.incident.selectType){
  2313. if(varLin.incident.selectType == '2'){
  2314. console.log(defaultFilterData)
  2315. $scope.searchkeys.selectType = {id:'2',name:'是'};
  2316. }else if(varLin.incident.selectType == '0'){
  2317. console.log(defaultFilterData)
  2318. $scope.searchkeys.selectType = {id:'0',name:'否'};
  2319. }
  2320. }
  2321. }
  2322. if(window.sessionStorage.getItem('isGoyuqi') === 'yes'){
  2323. $scope.selectTypeChange();
  2324. }else{
  2325. if(sessionStorage.getItem("searchincident")){
  2326. var ss = JSON.parse(sessionStorage.getItem("searchincident"));
  2327. delete ss.incident;
  2328. sessionStorage.setItem("searchincident",JSON.stringify(ss));
  2329. }
  2330. $scope.refreshData('expand-right');
  2331. }
  2332. $scope.timer = $interval(function () {
  2333. $scope.jry_refresh()
  2334. }, $rootScope.refreshTime);
  2335. $scope.$on('$destroy', function () {
  2336. $interval.cancel($scope.timer)
  2337. });
  2338. }]);
  2339. //操作按钮权限控制
  2340. app.controller('IncidentOperCtrl', ['$rootScope', '$scope', '$state', function ($rootScope, $scope, $state) {
  2341. var loginUser = $rootScope.user;
  2342. $scope.user = $rootScope.user;
  2343. $scope.chuli = false;
  2344. $scope.qiangdan = false;
  2345. $scope.huifang = false;
  2346. $scope.delFlag = false;
  2347. $scope.editFlag = false;//编辑
  2348. $scope.assignFlag = false;//指派
  2349. $scope.transferFlag = false;//转派
  2350. $scope.shijianliebiao_duty = false;//设置责任科室
  2351. for (var i = 0; i < loginUser.menu.length; i++) {
  2352. if (loginUser.menu[i].link == "shijianliebiao_chuli") {
  2353. $scope.chuli = true
  2354. }
  2355. if (loginUser.menu[i].link == "shijianliebiao_qiangdan") {
  2356. $scope.qiangdan = true
  2357. }
  2358. if (loginUser.menu[i].link == "shijianliebiao_huifang") {
  2359. $scope.huifang = true
  2360. }
  2361. if (loginUser.menu[i].link == "shijianliebiao_del") {
  2362. $scope.delFlag = true
  2363. }
  2364. if (loginUser.menu[i].link == "shijianliebiao_edit") {
  2365. $scope.editFlag = true
  2366. }
  2367. if (loginUser.menu[i].link == "shijianliebiao_assign") {
  2368. $scope.assignFlag = true
  2369. }
  2370. if (loginUser.menu[i].link == "shijianliebiao_transfer") {
  2371. $scope.transferFlag = true
  2372. }
  2373. if (loginUser.menu[i].link == "shijianliebiao_duty") {
  2374. $scope.shijianliebiao_duty = true
  2375. }
  2376. }
  2377. $scope.up = true;
  2378. $scope.fuwutaiRenYuan = false;//服务台人员
  2379. for (var i = 0; i < $rootScope.user.role.length; i++) {
  2380. if ($rootScope.user.role[i].role == '事件经理') {
  2381. $scope.up = false;
  2382. }
  2383. if ($rootScope.user.role[i].id == 29701) {
  2384. $scope.fuwutaiRenYuan = true;
  2385. }
  2386. }
  2387. if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  2388. // 当前登陆人和当前处理人相同,并且状态非已关闭
  2389. if ($rootScope.user.id == $scope.item.handlerUser.id && $scope.item.state.id != 1546) {
  2390. $scope.item.chaozuoPower = true;
  2391. }
  2392. }
  2393. $rootScope.callid = $scope.item.callID;
  2394. if ($scope.item.callID) {
  2395. $scope.item.listen = true;
  2396. } else {
  2397. $scope.item.listen = false;
  2398. }
  2399. $rootScope.user.group.forEach(function (item, v) {
  2400. if (item.id == $scope.item.candidateGroups) {
  2401. $scope.item.tiquPower = true;
  2402. }
  2403. })
  2404. //修改页面显示判断
  2405. $scope.jry_modify = function (item) {
  2406. var arrFlag = ['pending','handler'];
  2407. var stateFlag = arrFlag.includes(item.state.value)
  2408. return stateFlag && $scope.editFlag;
  2409. }
  2410. // 回访操作权限
  2411. for (var obj in $rootScope.user.role) {
  2412. if ($rootScope.user.role[obj].rolecode == 'call center') {
  2413. if ($scope.item.state.id == 1546) {
  2414. $scope.item.huifang = true;
  2415. } else {}
  2416. }
  2417. }
  2418. $scope.edit = function () {
  2419. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  2420. }
  2421. $scope.changeCenter = function () {
  2422. $scope.colobject.grid.appScope.changeClick($scope.item);
  2423. }
  2424. $scope.visit = function () {
  2425. $scope.colobject.grid.appScope.visit($scope.item);
  2426. }
  2427. // 指派
  2428. $scope.toAssign = function () {
  2429. $scope.colobject.grid.appScope.toAssign($scope.item);
  2430. }
  2431. // 转派
  2432. $scope.toTransfer = function () {
  2433. $scope.colobject.grid.appScope.toTransfer($scope.item);
  2434. }
  2435. // 删除事件
  2436. $scope.delSj = function () {
  2437. $scope.colobject.grid.appScope.delSj($scope.item);
  2438. }
  2439. // 新增维修记录
  2440. $scope.toHandlerLog = function () {
  2441. $scope.colobject.grid.appScope.toHandlerLog($scope.item);
  2442. }
  2443. // 设置责任科室
  2444. $scope.setDuty = function () {
  2445. $scope.colobject.grid.appScope.setDuty($scope.item);
  2446. }
  2447. $scope.play = function () { //record
  2448. $scope.colobject.grid.appScope.play($scope.item);
  2449. }
  2450. $scope.handler = function () {
  2451. $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
  2452. $scope.doComment($scope.item.id);
  2453. }
  2454. //查看
  2455. $scope.toDetail = function (data) {
  2456. console.log(data,$rootScope.isFuwutai);
  2457. if($rootScope.isFuwutai){
  2458. //角色是服务台人员
  2459. $state.go('app.incident.detail', {
  2460. formKey: 'incident_back',
  2461. pdKey: 'incident',
  2462. dataId: data.id,
  2463. taskId: data.taskId,
  2464. processInstanceId: data.processInstanceId
  2465. });
  2466. }else{
  2467. window.open(location.origin+'/#/app/incident/detail/incident_back/incident/'+data.id+'/'+data.taskId+'/'+data.processInstanceId+'//');
  2468. }
  2469. };
  2470. }]);
  2471. //操作按钮
  2472. app.directive('incidentoperator', function () {
  2473. return {
  2474. restrict: 'E',
  2475. scope: {
  2476. item: '=',
  2477. colobject: '='
  2478. },
  2479. controller: 'IncidentOperCtrl',
  2480. template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" style="text-align:left;">' +
  2481. '<a ng-click="toDetail(item)" class="bianjifont" >查看</a>' +
  2482. '<a ng-click="changeCenter()" ng-show="jry_modify(item)" class="luyinfont">编辑</a>' +
  2483. '<a ng-click="delSj()" ng-show="{{delFlag&&item.state.value!== \'deleted\'}}" class="assign" >删除</a><br>' +
  2484. '<a ng-click="edit()" ng-show="{{item.chaozuoPower&&chuli}}" class="bianjifont">处理</a>' +
  2485. '<a ng-click="handler()" ng-show="{{item.state.id != 1546 &&!item.handlerUser&&item.tiquPower&&qiangdan}}" class="bianjifont" >接单</a>' +
  2486. '<a ng-click="visit()" ng-show="{{item.huifang&&huifang}}" class="bianjifont">回访</a>' +
  2487. '<a ng-click="toAssign()" ng-show="{{(item.state.id==1543||item.state.id==1544)&&assignFlag}}" class="assign" >指派</a>' +
  2488. '<a ng-click="toTransfer()" ng-show="{{(item.state.id==1544)&&item.handlerUser&&item.handlerUser.id == user.id&&!assignFlag&&transferFlag}}" class="assign" >转派</a>' +
  2489. '<a ng-click="toHandlerLog()" ng-show="{{item.state.id==1544}}" class="assign" >维修进度</a>' +
  2490. '<a ng-click="setDuty()" ng-show="{{shijianliebiao_duty && (item.state.id==1545 || item.state.id==1546)}}" class="assign" >设置责任科室</a>' +
  2491. '</div></div>'
  2492. };
  2493. });