incidentCtrl.js 95 KB

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