incidentCtrl.js 98 KB

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