incidentCtrl.js 111 KB

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