incidentCtrl.js 115 KB

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