incidentCtrl.js 134 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278
  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', 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) {
  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. $scope.delFlagTab = false;
  9. for (var i = 0; i < $rootScope.user.menu.length; i++) {
  10. if ($rootScope.user.menu[i].link == "shijianliebiao_del") {
  11. $scope.delFlagTab = true
  12. }
  13. }
  14. // ----------------分割线 start-----------------
  15. console.log($state)
  16. // 故障地点下拉
  17. // $scope.addressModel = '';//文本输入内容
  18. $scope.address_arr = [];//故障地点所有数据
  19. $scope.addressFlag = false;//默认下拉框列表隐藏
  20. //点击文本框
  21. $scope.addressClickHandle = function () {
  22. $scope.searchkeys.houseNumber = $scope.searchkeys.houseNumber === undefined?'':$scope.searchkeys.houseNumber;
  23. $scope.getDepartmentList();
  24. angular.element('#bx_address_ul').scrollTop(0);
  25. }
  26. //修改文字,实时监听
  27. $scope.addressChangeHandle = _.debounce(function () {
  28. $scope.getDepartmentList();
  29. angular.element('#bx_address_ul').scrollTop(0);
  30. }, 500)
  31. //获取故障地点seimin
  32. $scope.getDepartmentList = function () {
  33. api_search_area.getAreaList({ "searchKey": $scope.searchkeys.houseNumber })
  34. .then(res => {
  35. if (res.state == 200) {
  36. $scope.address_arr = res.result;
  37. $scope.addressFlag = true;//显示
  38. }
  39. })
  40. .catch(err => {
  41. console.log(err);
  42. })
  43. }
  44. //下拉框列表选中
  45. $scope.addressItemClick = function (obj) {
  46. $scope.addressFlag = false;//隐藏
  47. $scope.searchkeys.houseNumber = obj.place ? obj.area.area + obj.place : obj.area;//文本框赋值
  48. }
  49. //点击空白处隐藏
  50. angular.element(document).on('click', function (e) {
  51. if (e.target !== angular.element('#bx_address').get(0)) {
  52. $scope.addressFlag = false;//隐藏
  53. }
  54. })
  55. // -----------------分割线 end----------------
  56. // 是否逾期seimin
  57. $scope.selectType = [
  58. { id: '2', name: '是' },
  59. { id: '0', name: '否' }
  60. ];
  61. // /是否逾期
  62. $scope.langs = i18nService.getAllLangs();
  63. $scope.lang = 'zh-cn';
  64. i18nService.setCurrentLang($scope.lang);
  65. $scope.myData = [];
  66. var loginUser = $rootScope.user;
  67. console.log(loginUser);
  68. $scope.daochu = false;
  69. for (var i = 0; i < loginUser.menu.length; i++) {
  70. if (loginUser.menu[i].link == "shijianliebiao_daochu") {
  71. $scope.daochu = true
  72. }
  73. }
  74. var loginuserGroup = "";
  75. for (var i = 0; i < $rootScope.user.group.length; i++) {
  76. if (i == 0) {
  77. loginuserGroup = $rootScope.user.group[i].id;
  78. } else {
  79. loginuserGroup = loginuserGroup + "," + $rootScope.user.group[i].id;
  80. }
  81. }
  82. //新增事件seimin
  83. $scope.goToAddIncident = function () {
  84. $state.go('app.incident.editor', {});
  85. }
  86. //全部事件权限
  87. // $scope.allright = false;
  88. // $scope.allrightnot = true;
  89. // for (var obj in $rootScope.user.role) {
  90. // if ($rootScope.user.role[obj].rolecode == 'incident manager' || $rootScope.user.role[obj].rolecode == 'call center') {
  91. // $scope.allright = true;
  92. // $scope.allrightnot = false;
  93. // }
  94. // }
  95. // 处理人,受理人,转派人
  96. var acceptUser;
  97. var pdKey = $state.current.pdKey;
  98. $scope.gridOptions = {};
  99. $scope.gridOptions.data = 'myData';
  100. $scope.gridOptions.enableColumnResizing = true;
  101. $scope.gridOptions.enableFiltering = false;
  102. $scope.gridOptions.enableGridMenu = true;
  103. $scope.gridOptions.enableSelectAll = true;
  104. $scope.gridOptions.enableRowSelection = true;
  105. $scope.gridOptions.showGridFooter = true;
  106. $scope.gridOptions.showColumnFooter = false;
  107. $scope.gridOptions.fastWatch = true;
  108. $scope.gridOptions.enableSorting = true;
  109. $scope.gridOptions.useExternalSorting = true;
  110. $scope.gridOptions.useExternalFiltering = false;
  111. $scope.gridOptions.useExternalPagination = true;
  112. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  113. $scope.gridOptions.paginationPageSize = 10;
  114. $scope.gridOptions.multiSelect = true;
  115. var mun = $scope.gridOptions.paginationPageSize;
  116. $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>";
  117. $scope.gridOptions.rowIdentity = function (row) {
  118. return row.id;
  119. };
  120. $scope.gridOptions.getRowIdentity = function (row) {
  121. return row.id;
  122. };
  123. $scope.states = [
  124. {
  125. id: "all",
  126. name: '全部的事件'
  127. },
  128. {
  129. id: "todo",
  130. name: '待我处理的事件'
  131. },
  132. {
  133. id: "create",
  134. name: '我创建的事件'
  135. },
  136. {
  137. id: "done",
  138. name: '我处理过的事件'
  139. }
  140. ];
  141. // for (var obj = 0; obj < $rootScope.user.role.length; obj++) {
  142. // if ($rootScope.user.role[obj].rolecode == 'incident manager' || $rootScope.user.role[obj].rolecode == 'call center') {
  143. // $scope.states = [
  144. // { id: "all", name: '全部的事件' },
  145. // { id: "todo", name: '待我处理的事件' },
  146. // { id: "create", name: '我创建的事件' },
  147. // { id: "done", name: '我处理过的事件' }
  148. // ];
  149. // }
  150. // }
  151. $scope.transferColor = function (item) {
  152. var color = "icon iconfont icon-zhengchang greenfont";
  153. if (item.colourInfo) {
  154. if (item.colourInfo.id == 1583) {
  155. color = "icon iconfont icon-yiyuqi redfont";
  156. } else if (item.colourInfo.id == 1584) {
  157. color = "iconfont icon-yuqixinxiu orangefont";
  158. }
  159. }
  160. return color;
  161. }
  162. $scope.transfertip = function (item) {
  163. var tip = "正常";
  164. if (item.colourInfo) {
  165. if (item.colourInfo.id == 1583) {
  166. tip = "已逾期";
  167. } else if (item.colourInfo.id == 1584) {
  168. tip = "即将逾期";
  169. } else if (item.colourInfo.id == 1586) {
  170. tip = "正常";
  171. }
  172. } else {
  173. // color = "white";
  174. }
  175. return tip;
  176. }
  177. $scope.transferstatus = function (item) {
  178. var statecolor = "#fc4c58";
  179. if (item.id == 2) { //待处理
  180. statecolor = "#fc4c58";
  181. } else if (item.id == 7) { //待审核
  182. statecolor = "#fcb44c";
  183. } else if (item.id == 3) { //请求重新指派
  184. statecolor = "#ebf902";
  185. } else if (item.id == 4) { //处理中
  186. statecolor = "#0aa5f5";
  187. } else if (item.id == 5) { //已解决
  188. statecolor = "#2edbb8";
  189. } else if (item.id == 6) { //已关闭
  190. statecolor = "#bbbbbb";
  191. }
  192. return statecolor;
  193. }
  194. if($scope.repairMain.valueconfig == 1){//报修人
  195. $scope.gridOptions.columnDefs = [
  196. {
  197. name: 'id',
  198. displayName: '',
  199. width: 35,
  200. cellTemplate: '<div>' +
  201. '<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>' +
  202. '</div>'
  203. },
  204. {
  205. name: 'item',
  206. displayName: '序号',
  207. width: 45,
  208. cellTemplate: '<div>' +
  209. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  210. '</div>'
  211. },
  212. {
  213. name: 'incidentsign',
  214. displayName: '事件单号',
  215. width: 120,
  216. cellTemplate: '<div>' +
  217. '<div class="ui-grid-cell-contents">{{row.entity.incidentsign}}</div>' +
  218. '</div>'
  219. },
  220. {
  221. name: 'requester.name',
  222. displayName: '报修人',
  223. width: '6%',
  224. minWidth: '90',
  225. enableSorting: false,
  226. cellTemplate: '<div>' +
  227. '<div class="ui-grid-cell-contents" >{{row.entity.requester.name}}</div>' +
  228. '</div>'
  229. },
  230. {
  231. name: 'requester.account',
  232. displayName: '学工号',
  233. width: '120',
  234. enableSorting: false,
  235. cellTemplate: '<div>' +
  236. '<div class="ui-grid-cell-contents" >{{row.entity.requester.account}}</div>' +
  237. '</div>'
  238. },
  239. {
  240. name: 'contactsInformation',
  241. displayName: '联系电话',
  242. width: '120',
  243. cellTemplate: '<div>' +
  244. '<div class="ui-grid-cell-contents">{{row.entity.contactsInformation}}</div>' +
  245. '</div>'
  246. },
  247. {
  248. name: 'category',
  249. displayName: '事件分类',
  250. width: '200',
  251. enableSorting: false,
  252. cellTemplate: '<div>' +
  253. '<div class="ui-grid-cell-contents">{{row.entity.category.category}}</div>' +
  254. '</div>'
  255. },
  256. {
  257. name: 'houseNumber',
  258. displayName: '校区区域地点',
  259. width: '14%',
  260. enableFiltering: false,
  261. cellTemplate: '<div><div class="ui-grid-cell-contents">{{grid.appScope.areaplace(row.entity)}}</div></div>'
  262. },
  263. {
  264. name: 'acceptUser.name',
  265. displayName: '受理人',
  266. width: '7%',
  267. minWidth: '80',
  268. enableSorting: false,
  269. cellTemplate: '<div>' +
  270. '<div class="ui-grid-cell-contents" >{{row.entity.acceptUser.name}}</div>' +
  271. '</div>'
  272. },
  273. {
  274. name: 'acceptDate',
  275. displayName: '登记时间',
  276. width: '10%',
  277. minWidth: '140',
  278. enableFiltering: false,
  279. cellTemplate: '<div><div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.acceptDate)}}</div></div>'
  280. },
  281. {
  282. name: 'groupORHandlerUser',
  283. displayName: '处理人/组',
  284. width: '10%',
  285. enableFiltering: false,
  286. cellTemplate: '<div>' +
  287. '<div class="ui-grid-cell-contents">' +
  288. '{{row.entity.groupORHandlerUser}}</div>' +
  289. '</div>'
  290. },
  291. {
  292. name: 'state.name',
  293. displayName: '状态',
  294. width: '7%',
  295. minWidth: '70',
  296. enableSorting: false,
  297. cellTemplate: '<div>' +
  298. '<div class="ui-grid-cell-contents" >{{row.entity.state.name}}</div>' +
  299. '</div>'
  300. },
  301. {
  302. name: '操作',
  303. enableSorting: false,
  304. width: 500,
  305. cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
  306. enableFiltering: false
  307. },
  308. ];
  309. if($scope.wxIncidentWithCmdb==1){
  310. let index = $scope.gridOptions.columnDefs.findIndex(v=>v.name == 'contactsInformation');
  311. $scope.gridOptions.columnDefs.splice(index,0,{
  312. name: 'assetId',
  313. displayName: '资产',
  314. width: 120
  315. },)
  316. }
  317. }else if($scope.repairMain.valueconfig == 2){//报修科室
  318. $scope.gridOptions.columnDefs = [
  319. {
  320. name: 'id',
  321. displayName: '',
  322. width: 35,
  323. cellTemplate: '<div>' +
  324. '<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>' +
  325. '</div>'
  326. },
  327. {
  328. name: 'item',
  329. displayName: '序号',
  330. width: 45,
  331. cellTemplate: '<div>' +
  332. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  333. '</div>'
  334. },
  335. {
  336. name: 'incidentsign',
  337. displayName: '事件单号',
  338. width: 120,
  339. cellTemplate: '<div>' +
  340. '<div class="ui-grid-cell-contents">{{row.entity.incidentsign}}</div>' +
  341. '</div>'
  342. },
  343. {
  344. name: 'department.dept',
  345. displayName: '报修科室',
  346. width: '6%',
  347. minWidth: '90',
  348. enableSorting: false,
  349. cellTemplate: '<div>' +
  350. '<div class="ui-grid-cell-contents" >{{row.entity.department.dept}}</div>' +
  351. '</div>'
  352. },
  353. {
  354. name: 'department.phone',
  355. displayName: '联系电话',
  356. width: '105',
  357. cellTemplate: '<div>' +
  358. '<div class="ui-grid-cell-contents">{{row.entity.department.phone}}</div>' +
  359. '</div>'
  360. },
  361. {
  362. name: 'category',
  363. displayName: '事件分类',
  364. width: '10%',
  365. enableSorting: false,
  366. cellTemplate: '<div>' +
  367. '<div class="ui-grid-cell-contents">{{row.entity.category.category}}</div>' +
  368. '</div>'
  369. },
  370. {
  371. name: 'houseNumber',
  372. displayName: '故障地点',
  373. width: '14%',
  374. enableFiltering: false,
  375. cellTemplate: '<div><div class="ui-grid-cell-contents">{{row.entity.houseNumber}}</div></div>'
  376. },
  377. {
  378. name: 'acceptUser.name',
  379. displayName: '受理人',
  380. width: '7%',
  381. minWidth: '80',
  382. enableSorting: false,
  383. cellTemplate: '<div>' +
  384. '<div class="ui-grid-cell-contents" >{{row.entity.acceptUser.name}}</div>' +
  385. '</div>'
  386. },
  387. {
  388. name: 'acceptDate',
  389. displayName: '登记时间',
  390. width: '10%',
  391. minWidth: '140',
  392. enableFiltering: false,
  393. cellTemplate: '<div><div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.acceptDate)}}</div></div>'
  394. },
  395. {
  396. name: 'groupORHandlerUser',
  397. displayName: '处理人/组',
  398. width: '10%',
  399. enableFiltering: false,
  400. cellTemplate: '<div>' +
  401. '<div class="ui-grid-cell-contents">' +
  402. '{{row.entity.groupORHandlerUser}}</div>' +
  403. '</div>'
  404. },
  405. {
  406. name: 'state.name',
  407. displayName: '状态',
  408. width: '7%',
  409. minWidth: '70',
  410. enableSorting: false,
  411. cellTemplate: '<div>' +
  412. '<div class="ui-grid-cell-contents" >{{row.entity.state.name}}</div>' +
  413. '</div>'
  414. },
  415. {
  416. name: '操作',
  417. enableSorting: false,
  418. width: 600,
  419. cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
  420. enableFiltering: false
  421. },
  422. ];
  423. }
  424. $scope.value = 10;
  425. $scope.decrement = function () {
  426. $scope.value = $scope.value - 1;
  427. };
  428. $scope.record = function () {
  429. api_text.record($rootScope.takes).then(function (data) {
  430. if (data.errno == 0) {
  431. $scope.busy = false;
  432. }
  433. })
  434. };
  435. $scope.transferTime = function (time) {
  436. return moment(time).format('YYYY-MM-DD HH:mm');
  437. }
  438. $scope.parameters = null;
  439. $scope.open = function ($event) {
  440. $event.preventDefault();
  441. $event.stopPropagation();
  442. $scope.opened = !$scope.opened;
  443. };
  444. $scope.endOpen = function ($event) {
  445. $event.preventDefault();
  446. $event.stopPropagation();
  447. $scope.startOpened = false;
  448. $scope.endOpened = !$scope.endOpened;
  449. };
  450. $scope.startOpen = function ($event) {
  451. $event.preventDefault();
  452. $event.stopPropagation();
  453. $scope.endOpened = false;
  454. $scope.startOpened = !$scope.startOpened;
  455. };
  456. $scope.othcode = {};
  457. $scope.searchkeys = {};
  458. // $scope.searchkeys = {selectType:{id:2,name:'是'}};//seimin
  459. // 事件分类
  460. var apple_selected, tree, treedata_avm, treedata_geography;
  461. $scope.my_tree_handler = function (branch) {
  462. //var _ref;
  463. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  464. api_cmdb.query({ 'sign': classify }).then(function (data) {
  465. var myData = Restangular.stripRestangular(data);
  466. // console.log(myData.data.node);
  467. if (myData.data && myData.status == 200) {
  468. var ret = myData.data;
  469. redrawSvg(myData);
  470. }
  471. });
  472. };
  473. $scope.my_data = [];
  474. function convertListToTree(data, treeMap) {
  475. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  476. var root = null; //Initially set our loop to null
  477. var parentNode = null;
  478. //loop over data
  479. for (var i = 0; i < data.length; i++) {
  480. var datum = data[i];
  481. //each node will have children, so let's give it a "children" poperty
  482. datum.children = [];
  483. //add an entry for this node to the map so that any future children can
  484. //lookup the parent
  485. idToNodeMap[datum.id] = datum;
  486. //Does this node have a parent?
  487. if (typeof datum.parent === "undefined" || datum.parent == null) {
  488. //Doesn't look like it, so this node is the root of the tree
  489. root = datum;
  490. treeMap[datum.id] = root;
  491. } else {
  492. //This node has a parent, so let's look it up using the id
  493. parentNode = idToNodeMap[datum.parent.id];
  494. //We don't need this property, so let's delete it.
  495. delete datum.parent;
  496. //Let's add the current node as a child of the parent node.
  497. parentNode.children.push(datum);
  498. }
  499. }
  500. return root;
  501. }
  502. function convertParentToChildList(data) {
  503. var treeMap = {};
  504. var list = [];
  505. convertListToTree(data, treeMap);
  506. angular.forEach(treeMap, function (item) {
  507. list.push(item);
  508. });
  509. return list;
  510. }
  511. $scope.my_tree = tree = {};
  512. // $scope.try_async_load = function() {
  513. // $scope.my_data = [];
  514. // $scope.select_treedata = [];
  515. // $scope.doing_async = true;
  516. // api_configure_data.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function(result) {
  517. // $scope.my_tree = result['list'];
  518. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  519. // $scope.doing_async = false;
  520. // // tree.expand_all();
  521. // //console.log(treelist);
  522. // });
  523. // };
  524. $scope.select_treedata = [];
  525. $scope.propTypeOptions = [];
  526. // $scope.try_async_load();
  527. // $scope.onFilterCallback = function(item) {
  528. // console.log(item);
  529. // if (angular.isDefined(item.children) && item.children.length >= 1) {
  530. // //not valid
  531. // } else {
  532. // var tempclassify = (item.item?item.item.prefix.toLowerCase():item.prefix.toLowerCase()) + (item.item?item.item.sign:item.sign);
  533. // $scope.gridApi.grid.options.paginationCurrentPage = 1;
  534. // $scope.cifilter_classic = tempclassify;
  535. // var memoryfilterData = {
  536. // "sign": tempclassify,
  537. // "idx": 0,
  538. // "sum": $scope.gridOptions.paginationPageSize
  539. // }
  540. // angular.extend($scope.memoryfilterData, memoryfilterData);
  541. // $scope.fileData["sign"]=tempclassify;
  542. // // $scope.memoryfilterData=memoryfilterData;
  543. // $scope.refreshData('expand-right', $scope.fileData);
  544. // // 专有属性
  545. // api_configure_form.renderTabForm(tempclassify).then(function(data) {
  546. // var myData = Restangular.stripRestangular(data);
  547. // angular.forEach(myData, function(item, index) {
  548. // if (index == 0) {
  549. // $scope.propTypeOptions = myData[0].form.fields;
  550. // } else {
  551. // angular.forEach(item.form.fields, function(itemdata) {
  552. // $scope.propTypeOptions.push(itemdata)
  553. // })
  554. // }
  555. // })
  556. // // $scope.propTypeOptions = myData[2].form.fields;
  557. // console.log($scope.propTypeOptions)
  558. // });
  559. // }
  560. // }
  561. // 报修科室
  562. $scope.getDept = function (key) {
  563. var postData = {
  564. "idx": 0,
  565. "sum": 10
  566. }
  567. if (key) {
  568. postData.department = { dept: key }
  569. }
  570. api_user_data.fetchDataList('department', postData).then(function (response) {
  571. if (response) {
  572. if (response.status = 200) {
  573. $scope.department = response.list;
  574. }
  575. }
  576. })
  577. }
  578. $scope.getDept();
  579. var apple_selected, tree, treedata_avm, treedata_geography;
  580. $scope.my_tree_handler = function (branch) {
  581. //var _ref;
  582. var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
  583. api_cmdb.query({
  584. 'sign': classify
  585. }).then(function (data) {
  586. var myData = Restangular.stripRestangular(data);
  587. // console.log(myData.data.node);
  588. if (myData.data && myData.status == 200) {
  589. var ret = myData.data;
  590. redrawSvg(myData);
  591. }
  592. });
  593. };
  594. //树形图
  595. // $scope.inspecttype = {};
  596. // 将事件分类搜索结果返回的数据整理成children模式
  597. function transform(nodes) {
  598. var treeConverter = {
  599. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  600. attributeName: 'id', //节点唯一标识符
  601. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  602. transform: function (node) { //转化递归函数,参数:一个待插入节点
  603. if (node.parent != null) { //该节点有父节点
  604. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  605. if (this.needFind) {
  606. for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
  607. if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
  608. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  609. }
  610. }
  611. }
  612. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  613. // delete node.parent; //删除该节点的parent属性,如果有的话
  614. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  615. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  616. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  617. } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
  618. // delete node.parent; //删除该节点的parent属性,如果有的话
  619. if (this.result == null) { //根节点不存在
  620. node.children = []; //给该节点增加children:[]属性
  621. return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  622. } else {
  623. node.children = [];
  624. // 顶级去重
  625. for (var i = 0; i < this.result.children.length; i++) {
  626. if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
  627. return this.result.children[i];
  628. }
  629. }
  630. this.result.children.push(node)
  631. return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  632. }
  633. }
  634. },
  635. getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  636. var _node = {};
  637. _node.children = [];
  638. this.result = _node; //重置根节点
  639. this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
  640. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  641. nodes.forEach(item => { //循环调用转化方法
  642. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  643. this.transform(item);
  644. })
  645. return this.result; //返回根节点
  646. }
  647. }
  648. var result = treeConverter.getWhole(nodes); //调用
  649. return result;
  650. }
  651. $scope.my_tree = {};
  652. $rootScope.bala1 = $scope.try_async_load = function (s, fn) {
  653. if (s) {
  654. var filterKeyword = s.filterKeyword;
  655. }
  656. var postData = {
  657. "idx": 0,
  658. "sum": 1000
  659. }
  660. if (filterKeyword) {
  661. postData.incidentcategory = { selectType: "pinyin_qs", category: filterKeyword }
  662. }
  663. $scope.my_data = [];
  664. $scope.doing_async = true;
  665. api_bpm_data.fetchDataList('incidentcategory', postData).then(function (response) {
  666. if (response.status == 200) {
  667. var data = response.list;
  668. if (filterKeyword) {
  669. data.forEach(e => {
  670. e.isExpanded = true;
  671. })
  672. var li = transform(data).children;
  673. console.log(li)
  674. fn(li)
  675. return;
  676. } else {
  677. var objects = [];
  678. for (var i = 0; i < data.length; i++) {
  679. var object = {};
  680. object.id = data[i].id;
  681. object.parent = data[i].parent;
  682. // if (data[i].parent && data[i].parent.id != 0) {
  683. // object.parent = data[i].parent.id;
  684. // }
  685. object.category = data[i].category;
  686. object.isExpanded = true;
  687. objects.push(object);
  688. }
  689. $scope.my_data = convertParentToChildList(objects);
  690. $scope.select_treedata = angular.copy($scope.my_data);
  691. }
  692. if ($scope.my_data.length > 0) {
  693. $scope.doing_async = false;
  694. }
  695. } else {
  696. SweetAlert.swal({
  697. title: "系统错误!",
  698. text: "请刷新重试!",
  699. type: "error"
  700. });
  701. }
  702. });
  703. };
  704. $scope.my_data = [];
  705. function convertListToTree(data, treeMap) {
  706. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  707. var root = null; //Initially set our loop to null
  708. var parentNode = null;
  709. //loop over data
  710. for (var i = 0; i < data.length; i++) {
  711. var datum = data[i];
  712. //each node will have children, so let's give it a "children" poperty
  713. datum.children = [];
  714. //add an entry for this node to the map so that any future children can
  715. //lookup the parent
  716. idToNodeMap[datum.id] = datum;
  717. //Does this node have a parent?
  718. if (typeof datum.parent === "undefined" || datum.parent == null) {
  719. //Doesn't look like it, so this node is the root of the tree
  720. root = datum;
  721. treeMap[datum.id] = root;
  722. } else {
  723. //This node has a parent, so let's look it up using the id
  724. parentNode = idToNodeMap[datum.parent.id];
  725. //We don't need this property, so let's delete it.
  726. delete datum.parent;
  727. //Let's add the current node as a child of the parent node.
  728. parentNode.children.push(datum);
  729. }
  730. }
  731. return root;
  732. console.log(root)
  733. }
  734. function convertParentToChildList(data) {
  735. var treeMap = {};
  736. var list = [];
  737. convertListToTree(data, treeMap);
  738. angular.forEach(treeMap, function (item) {
  739. list.push(item);
  740. });
  741. return list;
  742. }
  743. $scope.try_async_load();
  744. // $scope.select_treedata = [];
  745. $scope.propTypeOptions = [];
  746. $scope.deselectItem = function (item) {
  747. console.log(item)
  748. console.log($scope)
  749. }
  750. // 事件分类
  751. $scope.onFilterCallback = function (item) {
  752. // $scope.searchkeys.category={};
  753. console.log(item);
  754. if (item.item) {
  755. $scope.searchkeys.levelCategory = item = undefined;
  756. } else {
  757. $scope.searchkeys.levelCategory = item;
  758. }
  759. // if (angular.isDefined(item.children) && item.children.length >= 1) {
  760. // //not valid
  761. // } else {
  762. // var tempclassify = item.prefix.toLowerCase() + item.sign;
  763. // $scope.gridApi.grid.options.paginationCurrentPage = 1;
  764. // $scope.cifilter_classic = tempclassify;
  765. // var memoryfilterData = {
  766. // "sign": tempclassify,
  767. // "idx": 0,
  768. // "sum": $scope.gridOptions.paginationPageSize
  769. // }
  770. // angular.extend($scope.memoryfilterData, memoryfilterData)
  771. // // $scope.memoryfilterData=memoryfilterData;
  772. // $scope.refreshData('expand-right', $scope.memoryfilterData);
  773. // // 专有属性
  774. // var postData={
  775. // idx:0,
  776. // sum:1000
  777. // }
  778. // api_bpm_data.fetchDataList('incidentcategory',postData).then(function(data){
  779. // console.log(data)
  780. // var myData = Restangular.stripRestangular(data);
  781. // $scope.propTypeOptions = myData[2].form.fields;
  782. // // console.log($scope.propTypeOptions)
  783. // });
  784. // }
  785. }
  786. //状态
  787. $scope.state = [];
  788. // api_bpm_data.fetchDataList('incidentstatus', { "idx": 0, "sum": 100 }).then(function(response) {
  789. api_wechatfile.getDictionary({
  790. "type": "list",
  791. "key": "incident_status"
  792. }).then(function (response) {
  793. if (response) {
  794. if (response.status = 200) {
  795. $scope.state = response;
  796. if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).incident) {
  797. angular.forEach($scope.state, function (item) {
  798. if (item.id == JSON.parse(sessionStorage.getItem("searchincident")).incident.statusId) {
  799. $scope.othcode = {
  800. "state": item
  801. };
  802. }
  803. })
  804. }
  805. }
  806. }
  807. })
  808. if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).incident) {
  809. // angular.forEach($scope.state, function(item) {
  810. // if (item.code == JSON.parse(sessionStorage.getItem("searchincident")).incident.statusId) {
  811. // $scope.othcode = item.id;
  812. // }
  813. // })
  814. // $scope.othcode = JSON.parse(sessionStorage.getItem("searchincident")).incident.statusId;
  815. if (JSON.parse(sessionStorage.getItem("searchincident")).incident) {
  816. $scope.searchkeys = JSON.parse(sessionStorage.getItem("searchincident")).incident;
  817. }
  818. if ($scope.searchkeys.acceptDate) {
  819. $scope.searchkeys.acceptDate = new Date($scope.searchkeys.acceptDate);
  820. }
  821. if ($scope.searchkeys.acceptDateEnd) {
  822. $scope.searchkeys.acceptDateEnd = new Date($scope.searchkeys.acceptDateEnd);
  823. }
  824. // $scope.gridOptions.paginationCurrentPage = 1 + JSON.parse(sessionStorage.getItem("searchincident")).idx;
  825. }
  826. $scope.clear = function () {
  827. $scope.propTypeOptions = [];
  828. $scope.searchkeys = {};
  829. $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  830. $scope.othcode = {};
  831. $scope.try_async_load();
  832. var fildata = {
  833. "assignee": loginUser.id,
  834. "candidateGroups": loginuserGroup,
  835. "searchType": JSON.parse(sessionStorage.getItem("searchincident")).searchType,
  836. "idx": JSON.parse(sessionStorage.getItem("searchincident")).idx,
  837. "sum": JSON.parse(sessionStorage.getItem("searchincident")).sum
  838. }
  839. sessionStorage.removeItem("searchincident");
  840. fildata.assignee = loginUser.id;
  841. $scope.memoryfilterData = fildata;
  842. $scope.refreshData('expand-right', fildata);
  843. $interval.cancel($scope.timer);
  844. $scope.timer = $interval(function () {
  845. $scope.jry_refresh()
  846. }, $rootScope.refreshTime);
  847. }
  848. // 刷新
  849. $scope.jry_refresh = function () {
  850. var fildata = {};
  851. if (sessionStorage.searchincident) {
  852. fildata = JSON.parse(sessionStorage.getItem("searchincident"));
  853. } else {
  854. fildata = defaultFilterData;
  855. }
  856. if (fildata.incident && fildata.incident.category) {
  857. delete fildata.incident.category
  858. }
  859. fildata.idx = $scope.jry_idx;
  860. fildata.sum = $scope.jry_sum;
  861. $scope.refreshData2('expand-right', fildata);
  862. console.log($scope.cifilter_classic);
  863. }
  864. // 搜索
  865. $scope.chiceIncident = function (item, stateid) {
  866. if (stateid && stateid.id) {
  867. item.statusId = stateid.id;
  868. } else {
  869. item.statusId = undefined;
  870. }
  871. console.log(item)
  872. var fildata = {};
  873. if (sessionStorage.searchincident) {
  874. fildata = JSON.parse(sessionStorage.getItem("searchincident"));
  875. $scope.gridOptions.paginationCurrentPage = 1;
  876. fildata.idx = 0;
  877. } else {
  878. fildata = defaultFilterData;
  879. }
  880. // $scope.memoryfilterData = fildata;
  881. if (!fildata.incident) {
  882. fildata['incident'] = {};
  883. }
  884. // $scope.gridOptions.paginationCurrentPage = 1;
  885. if (item.acceptDate) {
  886. item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD 00:00:00');
  887. }
  888. if (item.acceptDateEnd) {
  889. // item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD 00:00:00');
  890. item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD 23:59:59')
  891. }
  892. // if (parameters) {
  893. // angular.extend(fildata, { 'idx': 0, 'sum': $scope.gridOptions.paginationPageSize })
  894. // angular.extend(fildata.incident, { 'acceptDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD 00:00:00'), 'acceptDateEnd': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59') })
  895. // }
  896. var transitiondata = angular.copy(item);
  897. angular.extend(fildata.incident, transitiondata)
  898. sessionStorage['searchincident'] = JSON.stringify(fildata);
  899. $scope.memoryfilterData = fildata;
  900. fildata.assignee = loginUser.id;
  901. // seimin
  902. if($scope.searchstate === 'all_del'){
  903. fildata.searchType = 'all';
  904. }else{
  905. fildata.searchType = $scope.searchstate;
  906. }
  907. console.log(fildata,78777);
  908. if(fildata.searchType === 'all'){
  909. if(fildata.incident&&fildata.incident.selectType){
  910. fildata.incident.selectType = fildata.incident.selectType.id;
  911. }
  912. }else{
  913. if(fildata.incident&&fildata.incident.selectType){
  914. delete fildata.incident.selectType;
  915. }
  916. }
  917. // /seimin
  918. $scope.refreshData('expand-right', fildata);
  919. $interval.cancel($scope.timer);
  920. $scope.timer = $interval(function () {
  921. $scope.jry_refresh()
  922. }, $rootScope.refreshTime);
  923. }
  924. //区域地点过滤
  925. $scope.key = {};
  926. api_user_data.fetchDataList('area', {
  927. "idx": 0,
  928. "sum": 1000
  929. }).then(function (response) {
  930. if (response) {
  931. if (response.status = 200) {
  932. $scope.outarea = response.list;
  933. }
  934. }
  935. })
  936. //报修人
  937. var getRequester = function (fieldatas) {
  938. if(fieldatas){
  939. api_user_data.fetchDataList('requester', fieldatas).then(function (data) {
  940. // console.log(data);
  941. $scope.requester = data.list
  942. });
  943. }else{
  944. api_user_data.fetchDataList('requester', {
  945. idx: 0,
  946. sum: 100
  947. }).then(function (data) {
  948. // console.log(data);
  949. $scope.requester = data.list
  950. });
  951. }
  952. }
  953. getRequester();
  954. //受理人,处理人
  955. var getUser = function (fieldatas, it) {
  956. api_user_data.fetchDataList('user', fieldatas).then(function (data) {
  957. // console.log(data);
  958. if (it == 1) {
  959. $scope.acceptUser = data.list;
  960. acceptUser = $scope.acceptUser;
  961. } else if (it == 2) {
  962. $scope.handlingPersonnelUser = data.list;
  963. // } else if (it == 3) {
  964. // $scope.acceptUser = data.list;
  965. // $scope.handlingPersonnelUser = data.list;
  966. }
  967. });
  968. }
  969. //受理人过滤
  970. $scope.onChangeacceptUser = function (key) {
  971. console.log(key)
  972. var filuser = {
  973. "idx": 0,
  974. "sum": 10,
  975. "user": {
  976. "name": key,
  977. 'selectType': "pinyin_qs"
  978. }
  979. }
  980. getUser(filuser, 1);
  981. }
  982. //处理人过滤
  983. $scope.onChangehandling = function (key) {
  984. var filuser = {
  985. "idx": 0,
  986. "sum": 10,
  987. "user": {
  988. "name": key,
  989. 'selectType': "pinyin_qs"
  990. }
  991. }
  992. getUser(filuser, 2);
  993. }
  994. //报修人过滤
  995. $scope.onChangeRequester= function (key) {
  996. var filuser = {
  997. "idx": 0,
  998. "sum": 10,
  999. "requester": {
  1000. "name": key,
  1001. 'selectType': 2
  1002. }
  1003. }
  1004. getRequester(filuser);
  1005. }
  1006. //报修科室过滤
  1007. $scope.onChangeDept = function (key) {
  1008. $scope.getDept(key)
  1009. }
  1010. //地点区域过滤
  1011. $scope.onChangearea = function (data) {
  1012. delete $scope.searchkeys.place;
  1013. if ($scope.memoryfilterData.incident) {
  1014. delete $scope.memoryfilterData.incident.place;
  1015. }
  1016. var fildata = {
  1017. "idx": 0,
  1018. "sum": 1000,
  1019. "place": {
  1020. area: {
  1021. id: data.area.id
  1022. }
  1023. }
  1024. };
  1025. api_user_data.fetchDataList('place', fildata).then(function (response) {
  1026. if (response) {
  1027. if (response.status = 200) {
  1028. $scope.outplace = response.list;
  1029. }
  1030. }
  1031. })
  1032. };
  1033. $scope.starttime = function (data) {
  1034. return moment(new Date(data)).format('YYYY-MM-DD')
  1035. }
  1036. $scope.overtime = function (data) {
  1037. return moment(new Date(data)).format('YYYY-MM-DD HH:mm')
  1038. }
  1039. $scope.areaplace = function (data) {
  1040. // if (data.area && data.place) {
  1041. // if (data.houseNumber) {
  1042. var str = ' ';
  1043. str += ' ' + (data.branch ? data.branch.hosName : ' ');
  1044. str += ' ' + (data.place ? (data.place.area ? data.place.area.area : ' ') : ' ');
  1045. str += ' ' + (data.place ? (data.place.place ? data.place.place : ' ') : ' ');
  1046. str += ' ' + (data.houseNumber ? data.houseNumber : ' ');
  1047. return str;
  1048. // } else {
  1049. // return data.area.area + ' ' + data.place.place;
  1050. // }
  1051. // } else if (data.area && !data.place) {
  1052. // if (data.houseNumber) {
  1053. // return data.area.area + ' ' + data.houseNumber;
  1054. // } else {
  1055. // return data.area.area;
  1056. // }
  1057. // } else if (!data.area && data.place) {
  1058. // if (data.houseNumber) {
  1059. // return data.place.place + ' ' + data.houseNumber;
  1060. // } else {
  1061. // return data.place.place;
  1062. // }
  1063. // }
  1064. }
  1065. //录音
  1066. // $scope.play = function (data) {
  1067. // var modalInstance = $modal.open({
  1068. // backdrop: "static",
  1069. // templateUrl: 'assets/views/incident/tpl/audio.html',
  1070. // controller: function ($rootScope, $scope, $modalInstance, $sce, $http, api_playservice, api_user_data) {
  1071. // var postData = {
  1072. // idx:0,
  1073. // sum:1,
  1074. // callRecord: {
  1075. // callId: data.callID
  1076. // }
  1077. // }
  1078. // api_user_data.fetchDataList('callrecord', postData).then(function (response) {
  1079. // if (response) {
  1080. // if (response.status = 200) {
  1081. // if(response.list[0]){
  1082. // $scope.audioUrl=$sce.trustAsResourceUrl(callIp+response.list[0].recordingFileName);
  1083. // }
  1084. // }
  1085. // }
  1086. // })
  1087. // $scope.cancel = function () {
  1088. // $modalInstance.dismiss('cancel');
  1089. // };
  1090. // $modalInstance.close();
  1091. // }
  1092. // });
  1093. // modalInstance.result.then(function (result) {
  1094. // }, function (reason) {
  1095. // $rootScope.setidle();
  1096. // });
  1097. // };
  1098. //录音
  1099. $scope.play = function (data) {
  1100. // console.log($scope.item.callID)
  1101. var modalInstance = $modal.open({
  1102. backdrop: "static",
  1103. templateUrl: 'assets/views/incident/tpl/audio.html',
  1104. controller: function ($rootScope, $scope, $modalInstance, $sce, $http, api_playservice) {
  1105. $rootScope.setbusy();
  1106. $scope.audioUrl = "";
  1107. $http({
  1108. url: "http://192.168.77.57:8088/recording/recording?callID=" + data.callID,
  1109. method: 'GET',
  1110. headers: {},
  1111. }).success(function (data, status, headers, config) {
  1112. $scope.data = {
  1113. "name": "视频",
  1114. "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
  1115. };
  1116. $scope.audioUrl = $sce.trustAsResourceUrl("http://" + data.rrpath);
  1117. }).error(function (data, status, headers, config) { });
  1118. $scope.download = function (contentId, filename) {
  1119. $http({
  1120. url: $scope.audioUrl,
  1121. method: 'GET',
  1122. headers: {
  1123. 'Content-type': 'application/octet-stream',
  1124. },
  1125. responseType: 'arraybuffer'
  1126. }).success(function (data, status, headers, config) {
  1127. var file = new Blob([data], {
  1128. type: 'application/octet-stream'
  1129. });
  1130. //trick to download store a file having its URL
  1131. var fileURL = URL.createObjectURL(file);
  1132. var a = document.createElement('a');
  1133. a.href = fileURL;
  1134. a.target = '_blank';
  1135. a.download = filename;
  1136. document.body.appendChild(a);
  1137. a.click();
  1138. }).error(function (data, status, headers, config) {
  1139. // console.log(data);
  1140. });
  1141. }
  1142. $scope.cancel = function () {
  1143. $modalInstance.dismiss('cancel');
  1144. };
  1145. $modalInstance.close();
  1146. }
  1147. });
  1148. modalInstance.result.then(function (result) {
  1149. // $rootScope.setidle();
  1150. }, function (reason) {
  1151. $rootScope.setidle();
  1152. });
  1153. };
  1154. $scope.jry_paging = "";
  1155. //列表排序
  1156. // sessionStorage.idx = 0;
  1157. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1158. $scope.gridApi = gridApi;
  1159. var index = 0;
  1160. var oldheader = {};
  1161. gridApi.grid.sortColumn = function (gridApi) {
  1162. if (oldheader.field) {
  1163. if (oldheader.field == gridApi.field) {
  1164. // index = 0;
  1165. } else {
  1166. index = 0;
  1167. }
  1168. }
  1169. index++;
  1170. oldheader = gridApi;
  1171. var fildata = $scope.memoryfilterData;
  1172. if (index % 3 == 0) {
  1173. delete $scope.memoryfilterData.incident;
  1174. fildata = $scope.memoryfilterData;
  1175. } else if (index % 3 == 1) {
  1176. if (fildata.incident) {
  1177. if (gridApi.field == "acceptDate") {
  1178. angular.extend(fildata.incident, {
  1179. "sort": gridApi.field
  1180. });
  1181. } else {
  1182. angular.extend(fildata.incident, {
  1183. "sort": gridApi.field + " desc , _incident.acceptDate"
  1184. });
  1185. }
  1186. } else {
  1187. if (gridApi.field == "acceptDate") {
  1188. angular.extend(fildata, {
  1189. 'incident': {
  1190. "sort": gridApi.field
  1191. }
  1192. });
  1193. } else {
  1194. angular.extend(fildata, {
  1195. 'incident': {
  1196. "sort": gridApi.field + " desc , _incident.acceptDate"
  1197. }
  1198. });
  1199. }
  1200. }
  1201. } else if (index % 3 == 2) {
  1202. if (fildata.incident) {
  1203. if (gridApi.field == "acceptDate") {
  1204. angular.extend(fildata.incident, {
  1205. "sort": gridApi.field,
  1206. "order": "asc"
  1207. });
  1208. } else {
  1209. angular.extend(fildata.incident, {
  1210. "sort": gridApi.field + " asc , _incident.acceptDate"
  1211. });
  1212. }
  1213. } else {
  1214. if (gridApi.field == "acceptDate") {
  1215. angular.extend(fildata, {
  1216. 'incident': {
  1217. "sort": gridApi.field,
  1218. "order": "asc"
  1219. }
  1220. });
  1221. } else {
  1222. angular.extend(fildata.incident, {
  1223. "sort": gridApi.field + " asc , _incident.acceptDate"
  1224. });
  1225. }
  1226. }
  1227. // angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
  1228. }
  1229. fildata.assignee = loginUser.id;
  1230. $scope.refreshData('expand-right', fildata);
  1231. }
  1232. $scope.jry_idx = 0;
  1233. $scope.jry_sum = 10;
  1234. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1235. var filtersData = $scope.memoryfilterData;
  1236. filtersData.idx = newPage - 1;
  1237. $scope.jry_paging = newPage - 1;
  1238. $scope.jry_idx = newPage - 1;
  1239. filtersData.sum = pageSize;
  1240. $scope.jry_sum = pageSize;
  1241. if (JSON.parse(sessionStorage.getItem("searchincident")).idx != filtersData.idx || JSON.parse(sessionStorage.getItem("searchincident")).sum != filtersData.sum) {
  1242. filtersData.assignee = loginUser.id;
  1243. $scope.refreshData('expand-right', filtersData);
  1244. }
  1245. // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
  1246. });
  1247. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  1248. // data.grid.appScope.selected.items = data.entity
  1249. // });
  1250. $scope.Change = function (upTypes) {
  1251. if (angular.isDefined($scope.selected.items)) {
  1252. if (angular.isDefined(upTypes) && upTypes == 'upincident') {
  1253. var data = {
  1254. cancelUrl: 'app.incident.list',
  1255. model: {
  1256. problem: {
  1257. title: $scope.selected.items.title,
  1258. des: $scope.selected.items.description,
  1259. proposePerson: $scope.selected.items.handlerUser,
  1260. source: {
  1261. id: 1,
  1262. code: 1,
  1263. name: ' 事件 '
  1264. },
  1265. incident: $scope.selected.items
  1266. }
  1267. }
  1268. }
  1269. $state.go('app.problem.incident', {
  1270. pdKey: 'incident',
  1271. dataId: $scope.selected.items.id,
  1272. processInstanceId: $scope.selected.items.processInstanceId,
  1273. 'model': JSON.stringify(data)
  1274. });
  1275. } else if (angular.isDefined(upTypes) && upTypes == 'upchange') {
  1276. var data = {
  1277. cancelUrl: 'app.incident.list',
  1278. model: {
  1279. change: {
  1280. title: $scope.selected.items.title,
  1281. description: $scope.selected.items.description,
  1282. requestingPerson: $scope.selected.items.handlerUser,
  1283. source: {
  1284. id: 1,
  1285. code: 1,
  1286. name: ' 事件 '
  1287. },
  1288. incident: $scope.selected.items
  1289. }
  1290. }
  1291. }
  1292. // var data={cancelUrl:'app.incident.list'}
  1293. $state.go('app.change.incident', {
  1294. pdKey: 'incident',
  1295. dataId: $scope.selected.items.id,
  1296. processInstanceId: $scope.selected.items.processInstanceId,
  1297. 'model': JSON.stringify(data)
  1298. });
  1299. }
  1300. }
  1301. }
  1302. $scope.selected = {
  1303. items: []
  1304. }
  1305. gridApi.core.on.filterChanged($scope, function () {
  1306. var grid = this.grid;
  1307. if ($rootScope.user.group) {
  1308. var filtersData = {
  1309. "assignee": loginUser.id,
  1310. "candidateGroups": loginuserGroup,
  1311. idx: 0,
  1312. sum: mun
  1313. };
  1314. } else {
  1315. var filtersData = {
  1316. "assignee": loginUser.id,
  1317. idx: 0,
  1318. sum: mun
  1319. };
  1320. }
  1321. angular.forEach(grid.columns, function (item) {
  1322. if (item.enableFiltering) {
  1323. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  1324. filtersData = $scope.memoryfilterData
  1325. if (angular.isUndefined(filtersData['incident'])) {
  1326. filtersData['incident'] = {};
  1327. }
  1328. if (item.field == 'department.dept') {
  1329. filtersData['incident']['department'] = {};
  1330. filtersData.incident.department['department'] = item.filters[0].term;
  1331. } else if (item.field == 'handlingPersonnelUser.name') {
  1332. filtersData['incident']['handlingPersonnelUser'] = {};
  1333. filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
  1334. } else if (item.field == 'requester.account') {
  1335. filtersData['incident']['requester'] = {};
  1336. filtersData.incident.requester['account'] = item.filters[0].term;
  1337. } else if (item.field == 'acceptUser.name') {
  1338. filtersData['incident']['acceptUser'] = {};
  1339. filtersData.incident.acceptUser['name'] = item.filters[0].term;
  1340. } else {
  1341. filtersData['incident'][item.field] = item.filters[0].term;
  1342. }
  1343. }
  1344. }
  1345. });
  1346. filtersData.idx = 0;
  1347. filtersData.assignee = loginUser.id;
  1348. $scope.memoryfilterData = filtersData;
  1349. $scope.refreshData('expand-right', filtersData);
  1350. });
  1351. };
  1352. //当前人是否分组
  1353. if ($rootScope.user.group) {
  1354. if ($rootScope.user.group.length == 0) {
  1355. SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
  1356. } else {
  1357. $scope.memoryfilterData = defaultFilterData = {
  1358. "assignee": loginUser.id,
  1359. "candidateGroups": loginuserGroup,
  1360. "searchType": "all",
  1361. "idx": 0,
  1362. "sum": mun
  1363. };
  1364. }
  1365. } else {
  1366. $scope.memoryfilterData = defaultFilterData = {
  1367. "assignee": loginUser.id,
  1368. "searchType": "all",
  1369. "idx": 0,
  1370. "sum": mun
  1371. };
  1372. }
  1373. //打印
  1374. $scope.open = function (data) {
  1375. var modalInstance = $modal.open({
  1376. templateUrl: 'assets/views/incident/tpl/print.html',
  1377. controller: function ($scope, $modalInstance) {
  1378. $scope.printdata = data;
  1379. if (!data.emergency) {
  1380. data['emergency'] = {};
  1381. }
  1382. if (!data.influence) {
  1383. data['influence'] = {};
  1384. }
  1385. if (!data.place) {
  1386. data['place'] = {};
  1387. }
  1388. if (!data.influence) {
  1389. data['influence'] = {};
  1390. }
  1391. if (!data.emergency) {
  1392. data['emergency'] = {};
  1393. }
  1394. if (!data.influence) {
  1395. data['influence'] = {};
  1396. }
  1397. var height = $(".groundborder").height()
  1398. // console.log(height)
  1399. $scope.printrequest = [{
  1400. name: "事件单号",
  1401. value: data.incidentsign
  1402. },
  1403. {
  1404. name: "事件主题",
  1405. value: data.title
  1406. },
  1407. {
  1408. name: "事件分类",
  1409. value: data.category.category
  1410. },
  1411. {
  1412. name: "紧急度",
  1413. value: data.emergency.name
  1414. },
  1415. {
  1416. name: "影响度",
  1417. value: data.influence.name
  1418. },
  1419. {
  1420. name: "优先级",
  1421. value: data.priority.name
  1422. }
  1423. ];
  1424. $scope.printrequest['requester'] = [{
  1425. nameone: "用户姓名",
  1426. valueone: data.requester.name,
  1427. nametwo: "联系电话",
  1428. valuetwo: data.requester.mphone
  1429. },
  1430. {
  1431. nameone: "故障地点",
  1432. valueone: data.place.place,
  1433. nametwo: "申报时间",
  1434. valuetwo: data.acceptDate
  1435. }
  1436. ];
  1437. // $scope.printrequest['requester']=[{name:"用户姓名",value:data.requester.name},
  1438. // {name:"联系电话",value:data.requester.mphone},
  1439. // {name:"故障地点",value:data.place.place},
  1440. // {name:"申报时间",value:data.responseTime}];
  1441. $scope.printrequest['incident'] = [{
  1442. nameone: "故障工单",
  1443. valueone: data.incidentsign,
  1444. nametwo: "故障分类",
  1445. valuetwo: data.category.category
  1446. }];
  1447. $scope.printrequest['handler'] = [{
  1448. name: "故障描述",
  1449. value: data.description
  1450. },
  1451. {
  1452. name: "处理人",
  1453. value: data.handlingPersonnelUser ? data.handlingPersonnelUser.name : ''
  1454. },
  1455. // { name: "处理人", value: data.requester ? data.requester.name : '' }
  1456. ];
  1457. // {name:"处理结果",value:data.handleResult}];
  1458. // {name:"用户评价",value:''},
  1459. // {name:"满意度",value:''},
  1460. // {name:"用户签字",value:''}];
  1461. $scope.cancel = function () {
  1462. $modalInstance.dismiss('cancel');
  1463. };
  1464. },
  1465. size: 'lg'
  1466. });
  1467. }
  1468. //新建事件
  1469. $scope.newincident = function (data) {
  1470. $state.go('app.incident.editor', {});
  1471. };
  1472. //编辑
  1473. $scope.selectRowFunction = function (data) {
  1474. $state.go('app.incident.editor', {
  1475. taskId: data.taskId,
  1476. processInstanceId: data.processInstanceId,
  1477. dataId: data.id,
  1478. // type:1
  1479. });
  1480. };
  1481. // //双击查看详情
  1482. $scope.onDblClick = function (data) {
  1483. console.log(data);
  1484. // console.log('data='+JSON.stringify(data));
  1485. //$state.go('app.detail',{taskId:data.taskId,processInstanceId: data.processInstanceId});
  1486. $state.go('app.incident.detail', {
  1487. formKey: 'incident_back',
  1488. pdKey: 'incident',
  1489. dataId: data.entity.id,
  1490. taskId: data.entity.taskId,
  1491. processInstanceId: data.entity.processInstanceId
  1492. });
  1493. };
  1494. //修改
  1495. $scope.changeClick = function (data) {
  1496. $state.go('app.incident.detail', {
  1497. formKey: 'incident_change',
  1498. pdKey: 'incident',
  1499. dataId: data.id,
  1500. taskId: data.taskId,
  1501. processInstanceId: data.processInstanceId
  1502. });
  1503. };
  1504. //回访
  1505. $scope.visit = function (data) {
  1506. $state.go('app.incident.detail', {
  1507. formKey: 'incident_visit',
  1508. pdKey: 'incident',
  1509. dataId: data.id,
  1510. taskId: data.taskId,
  1511. processInstanceId: data.processInstanceId
  1512. });
  1513. };
  1514. //查看
  1515. $scope.followFunction = function (data) {
  1516. //console.log('data='+JSON.stringify(data));
  1517. console.log(data);
  1518. $state.go('app.detail', {
  1519. formKey: 'statusform',
  1520. pdKey: 'incident',
  1521. dataId: data.id,
  1522. processInstanceId: data.processInstanceId
  1523. });
  1524. };
  1525. // 升级
  1526. $scope.upgrade = function (data) {
  1527. console.log(data);
  1528. console.log('升级');
  1529. // 弹窗下拉菜单单选
  1530. } // 转派
  1531. $scope.rotate = function (data) {
  1532. console.log(data);
  1533. console.log('转派');
  1534. // 弹窗下拉菜单单选
  1535. } // 协同
  1536. $scope.cooperate = function (data) {
  1537. console.log(data);
  1538. console.log('协同');
  1539. // 弹窗下拉菜单多选
  1540. }
  1541. // 升级问题
  1542. $scope.problem = function (data) {
  1543. // console.log(data);
  1544. delete data.item;
  1545. delete data.chaozuoPower;
  1546. delete data.coordination;
  1547. delete data.listen;
  1548. // console.log(data);
  1549. $state.go('app.problem.incident', {
  1550. 'model': JSON.stringify(data)
  1551. });
  1552. }
  1553. //变更升级
  1554. $scope.configuration = function (data) {
  1555. $state.go('app.change.incident', {
  1556. 'model': JSON.stringify(data)
  1557. });
  1558. };
  1559. //协同人
  1560. $scope.coordination = function (data) {
  1561. var modalInstance = $modal.open({
  1562. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  1563. controller: function ($scope, $modalInstance, i18nService, $timeout, api_bpm_domain, api_user_data) {
  1564. $scope.langs = i18nService.getAllLangs();
  1565. $scope.lang = 'zh-cn';
  1566. i18nService.setCurrentLang($scope.lang);
  1567. $scope.gridOptions = {};
  1568. $scope.gridOptions.data = 'myData';
  1569. $scope.gridOptions.enableColumnResizing = true;
  1570. $scope.gridOptions.enableFiltering = true;
  1571. $scope.gridOptions.enableGridMenu = true;
  1572. $scope.gridOptions.showGridFooter = true;
  1573. $scope.gridOptions.showColumnFooter = true;
  1574. $scope.gridOptions.fastWatch = true;
  1575. $scope.gridOptions.useExternalFiltering = true;
  1576. $scope.gridOptions.useExternalPagination = true;
  1577. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1578. $scope.gridOptions.paginationPageSize = 10;
  1579. $scope.gridOptions.multiSelect = false;
  1580. $scope.gridOptions.rowIdentity = function (row) {
  1581. return row.id;
  1582. };
  1583. $scope.gridOptions.getRowIdentity = function (row) {
  1584. return row.id;
  1585. };
  1586. $scope.gridOptions.columnDefs = [
  1587. // { name:'id', width:80, enableFiltering:false},
  1588. {
  1589. name: 'account',
  1590. displayName: '账号',
  1591. width: 140
  1592. },
  1593. {
  1594. name: 'name',
  1595. displayName: '名称',
  1596. width: 100
  1597. },
  1598. {
  1599. name: 'gender',
  1600. displayName: '性别',
  1601. width: 140,
  1602. enableFiltering: false
  1603. },
  1604. {
  1605. name: 'phone',
  1606. displayName: '电话',
  1607. width: 100,
  1608. enableFiltering: false
  1609. },
  1610. {
  1611. name: 'email',
  1612. displayName: '邮件',
  1613. width: 100,
  1614. enableFiltering: false
  1615. },
  1616. {
  1617. name: 'dept.dept',
  1618. displayName: '科室',
  1619. width: 100,
  1620. enableFiltering: false
  1621. },
  1622. {
  1623. name: 'group[0].groupName',
  1624. displayName: '职位',
  1625. width: 100,
  1626. enableFiltering: false
  1627. }
  1628. ];
  1629. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1630. $scope.gridApi = gridApi;
  1631. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  1632. var filtersData = $scope.memoryfilterData;
  1633. filtersData.idx = newPage - 1;
  1634. filtersData.sum = pageSize;
  1635. $scope.loadData(filtersData);
  1636. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  1637. });
  1638. gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
  1639. scope.grid.appScope.selected.items[0] = scope.entity;
  1640. // $scope.selected.items[0] = scope.entity;
  1641. });
  1642. gridApi.core.on.filterChanged($scope, function () {
  1643. var grid = this.grid;
  1644. var filtersData = {
  1645. idx: 0,
  1646. sum: 10,
  1647. "user": {
  1648. "roledata": {
  1649. "rolecode": options.model.currentRole
  1650. },
  1651. "selectType": "1"
  1652. }
  1653. };
  1654. angular.forEach(grid.columns, function (item) {
  1655. if (item.enableFiltering) {
  1656. //console.log("filtersData="+JSON.stringify(filtersData))
  1657. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  1658. if (angular.isUndefined(filtersData['user'])) {
  1659. filtersData['user'] = {};
  1660. }
  1661. filtersData['user'][item.field] = item.filters[0].term;
  1662. }
  1663. }
  1664. });
  1665. $scope.memoryfilterData = filtersData;
  1666. $scope.loadData(filtersData);
  1667. });
  1668. };
  1669. $scope.selected = {
  1670. items: []
  1671. }
  1672. var filterData = {
  1673. "idx": 0,
  1674. "sum": 10,
  1675. "user": {
  1676. "roledata": {
  1677. "rolecode": 'first-line support'
  1678. },
  1679. "selectType": "1"
  1680. }
  1681. }
  1682. $scope.loadData = function (filterData) {
  1683. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  1684. api_user_data.fetchDataList('user', filterData).then(function (data) {
  1685. var myData = Restangular.stripRestangular(data);
  1686. $scope.gridOptions.totalItems = myData.totalNum;
  1687. $scope.myData = myData.list;
  1688. });
  1689. };
  1690. $scope.loadData({
  1691. idx: 0,
  1692. sum: 10,
  1693. "user": {
  1694. "roledata": {
  1695. "rolecode": 'first-line support'
  1696. },
  1697. "selectType": "1"
  1698. }
  1699. });
  1700. $scope.ok = function () {
  1701. $modalInstance.close($scope.selected.items);
  1702. };
  1703. $scope.cancel = function () {
  1704. $modalInstance.dismiss('cancel');
  1705. };
  1706. },
  1707. size: 'lg'
  1708. });
  1709. modalInstance.result.then(function (selectedItem) {
  1710. if (selectedItem) {
  1711. var filterData = {
  1712. "assginee": selectedItem[0].id
  1713. }
  1714. api_bpm_domain.delegateTask(data.taskId, filterData).then(function (data) {
  1715. if (data && data.status == 200) {
  1716. SweetAlert.swal("添加成功!", "添加协同人成功", "success");
  1717. $scope.memoryfilterData.assignee = loginUser.id;
  1718. $scope.refreshData('expand-right', $scope.memoryfilterData);
  1719. } else {
  1720. SweetAlert.swal("添加失败!", "请稍候重试", "error");
  1721. }
  1722. // var myData = Restangular.stripRestangular(data);
  1723. // $scope.gridOptions.totalItems = myData.totalNum;
  1724. // $scope.myData = myData.list;
  1725. });
  1726. }
  1727. });
  1728. }
  1729. // $scope.onDblClick = function(row){
  1730. // console.log(row.entity);
  1731. // if($rootScope.user.id==row.entity.handlerUser.id){$state.go('app.incident.editor',{taskId:row.entity.taskId,processInstanceId: row.entity.processInstanceId});}
  1732. // else{$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: row.entity.id});}
  1733. // };
  1734. /*
  1735. appScopeProvider: {
  1736. onDblClick : function(row) {
  1737. var url = '//google.com';
  1738. $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
  1739. }
  1740. },
  1741. rowTemplate: "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" ui-grid-cell ></div>"
  1742. */
  1743. //删除
  1744. $scope.eventDeleted = function (event) {
  1745. SweetAlert.swal({
  1746. title: "确认删除?",
  1747. text: "删除的数据不可恢复,请确认继续操作!",
  1748. type: "warning",
  1749. showCancelButton: true,
  1750. confirmButtonColor: "#DD6B55",
  1751. confirmButtonText: "继续删除",
  1752. cancelButtonText: "取消操作",
  1753. closeOnConfirm: false,
  1754. closeOnCancel: false
  1755. }, function (isConfirm) {
  1756. if (isConfirm) {
  1757. api_bpm_schedule.remove([event.id]).then(function (response) {
  1758. if (response.status == 200) {
  1759. $scope.events.splice(event.id, 1); //有修改的一行
  1760. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  1761. } else {
  1762. SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
  1763. }
  1764. });
  1765. } else {
  1766. SweetAlert.swal("操作取消", "数据安全", "error");
  1767. }
  1768. });
  1769. };
  1770. //导出
  1771. $scope.export = function () {
  1772. // api_bpm_data.downDataModel("incident", 3, $scope.memoryfilterData).then(function(data) {
  1773. // console.log(data)
  1774. // var file = new Blob([data], {
  1775. // // type: 'application/octet-stream'
  1776. // type: 'application/vnd.ms-excel'
  1777. // });
  1778. // //trick to download store a file having its URL
  1779. // var fileURL = URL.createObjectURL(file);
  1780. // var a = document.createElement('a');
  1781. // a.href = fileURL;
  1782. // a.target = '_blank';
  1783. // a.download = '事件列表.xls';
  1784. // document.body.appendChild(a);
  1785. // a.click();
  1786. // })
  1787. // $scope.ldloading[style.replace('-', '_')] = true;
  1788. console.log($scope.memoryfilterData)
  1789. var filadata = angular.copy($scope.memoryfilterData);
  1790. filadata.sum = 10000;
  1791. console.log($scope.filadata)
  1792. $http({
  1793. url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
  1794. method: 'POST',
  1795. data: JSON.stringify(filadata),
  1796. headers: {
  1797. // 'Content-type': 'application/xls',
  1798. 'Accept': '*/*'
  1799. },
  1800. responseType: 'arraybuffer'
  1801. }).success(function (data, status, headers, config) {
  1802. // $scope.ldloading.zoom_in = false;
  1803. var file = new Blob([data], {
  1804. type: 'application/vnd.ms-excel'
  1805. });
  1806. //trick to download store a file having its URL
  1807. var fileURL = URL.createObjectURL(file);
  1808. var a = document.createElement('a');
  1809. a.href = fileURL;
  1810. a.target = '_blank';
  1811. a.download = '事件列表.xls';
  1812. document.body.appendChild(a);
  1813. a.click();
  1814. }).error(function (data, status, headers, config) {
  1815. // $scope.ldloading.zoom_in = false;
  1816. console.log(data);
  1817. });
  1818. }
  1819. //事件提取
  1820. $scope.acceptTaskAction = function (model) {
  1821. var modalInstance = $modal.open({
  1822. templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
  1823. controller: function ($scope, $modalInstance, APIService, modelData, currentUserId, Alert) {
  1824. var receiveTask = function (receive_code, modelData) {
  1825. var data = {
  1826. 'receive_code': receive_code
  1827. };
  1828. if (modelData) {
  1829. return {
  1830. taskId: modelData.taskId,
  1831. data: data
  1832. };
  1833. } else {
  1834. return 'error';
  1835. }
  1836. };
  1837. $scope.title = "提示";
  1838. $scope.connect = "确认抢单?";
  1839. $scope.ok = function () {
  1840. //接收任务//请求重新指派
  1841. var data = receiveTask($scope.receive_code, modelData);
  1842. APIService.claimAndCompletedTask(data.taskId, {
  1843. userId: currentUserId,
  1844. receive_code: "handler"
  1845. }).then(function (response) {
  1846. if (response.status == 200) {
  1847. Alert.swal({
  1848. title: "操作成功!",
  1849. confirmButtonColor: "#007AFF",
  1850. type: "success"
  1851. });
  1852. $modalInstance.close('success');
  1853. } else if (response.status == 500) {
  1854. Alert.swal({
  1855. title: "操作失败",
  1856. text: "该事件已被提取,请刷新页面!",
  1857. type: "error"
  1858. });
  1859. $modalInstance.close('success');
  1860. } else {
  1861. Alert.swal({
  1862. title: "操作失败",
  1863. text: "操作失败, 请稍后再试!",
  1864. type: "error"
  1865. });
  1866. }
  1867. });
  1868. }
  1869. $scope.cancel = function () {
  1870. $modalInstance.dismiss('cancel');
  1871. }
  1872. },
  1873. size: 'sm',
  1874. resolve: {
  1875. APIService: function () {
  1876. return api_bpm_domain;
  1877. },
  1878. modelData: function () {
  1879. return model;
  1880. },
  1881. currentUserId: function () {
  1882. return loginUser.id;
  1883. },
  1884. Alert: function () {
  1885. return SweetAlert;
  1886. }
  1887. }
  1888. });
  1889. modalInstance.result.then(function (selectedItem) {
  1890. if (selectedItem == 'success') {
  1891. defaultFilterData.assignee = loginUser.id;
  1892. $scope.refreshData('expand-right', defaultFilterData);
  1893. }
  1894. });
  1895. }
  1896. // 升级弹窗
  1897. $scope.upgrade = function (model) {
  1898. console.log(model)
  1899. var modalInstance = $modal.open({
  1900. templateUrl: 'assets/views/incident/tpl/upgrade.tpl.html',
  1901. controller: function ($scope, $modalInstance, api_bpm, modelData, currentUserId, Alert, api_user_data) {
  1902. console.log(model);
  1903. $scope.roleList = {
  1904. 'idx': 0,
  1905. 'sum': 100,
  1906. 'user': {
  1907. 'roledata': {
  1908. 'rolecode': ''
  1909. },
  1910. 'groupdata': {
  1911. 'id': ''
  1912. },
  1913. 'selectType': 1
  1914. }
  1915. }
  1916. for (var i = 0; i < loginUser.role.length; i++) {
  1917. // console.log(loginUser.role[i])
  1918. if (loginUser.role[i].role == '一线支持人员') {
  1919. $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
  1920. $scope.upRole = '二线支持人员';
  1921. }
  1922. if (loginUser.role[i].role == '二线支持人员') {
  1923. $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
  1924. $scope.upRole = '事件经理';
  1925. }
  1926. }
  1927. var userId = loginUser.id;
  1928. var taskId = model.taskId;
  1929. var postData = {};
  1930. var formKey = model.formKey;
  1931. var processInstanceId = model.processInstanceId;
  1932. $scope.choosUser = {};
  1933. api_configure_form.renderForm(formKey, userId, processInstanceId).then(function (data) {
  1934. postData = data.model;
  1935. })
  1936. $scope.choosUser = {};
  1937. api_user_data.fetchDataList('group', {
  1938. "idx": 0,
  1939. "sum": 100
  1940. }).then(function (data) {
  1941. $scope.group = data.list;
  1942. })
  1943. $scope.onChangeGroup = function (item) {
  1944. $scope.user = [];
  1945. console.log(item);
  1946. console.log($scope.choosUser.group)
  1947. $scope.roleList.user.groupdata.id = $scope.choosUser.group.id
  1948. console.log($scope.roleList)
  1949. if ($scope.choosUser.group) {
  1950. api_user_data.fetchDataList('user', $scope.roleList).then(function (data) {
  1951. console.log(data);
  1952. if (data.list.length == 0) {
  1953. Alert.swal({
  1954. title: "暂无处理人数据",
  1955. text: "该工作组暂无升级对象!",
  1956. type: "error"
  1957. });
  1958. return;
  1959. } else {
  1960. $scope.user = data.list;
  1961. }
  1962. })
  1963. }
  1964. }
  1965. $scope.ok = function () {
  1966. if ($scope.choosUser.handlerUser) {
  1967. postData.handler_code = 'function';
  1968. postData.incident.handlerUser = $scope.choosUser.handlerUser;
  1969. postData.incident.assignee = postData.assignee = $scope.choosUser.handlerUser.id;
  1970. console.log(postData);
  1971. } else {
  1972. Alert.swal({
  1973. title: "操作失败",
  1974. text: "请选择升级对象信息!",
  1975. type: "error"
  1976. });
  1977. return;
  1978. }
  1979. api_bpm.upgrade(postData, taskId, userId, 'completeTask').then(function (response) {
  1980. console.log(response)
  1981. if (response.status == 200) {
  1982. Alert.swal({
  1983. title: "操作成功!",
  1984. confirmButtonColor: "#007AFF",
  1985. type: "success"
  1986. });
  1987. $modalInstance.close('success');
  1988. } else if (response.status == 500) {
  1989. Alert.swal({
  1990. title: "操作失败",
  1991. text: "该事件已被提取,请刷新页面!",
  1992. type: "error"
  1993. });
  1994. $modalInstance.close('success');
  1995. } else {
  1996. Alert.swal({
  1997. title: "操作失败",
  1998. text: "操作失败, 请稍后再试!",
  1999. type: "error"
  2000. });
  2001. }
  2002. });
  2003. }
  2004. $scope.cancel = function () {
  2005. $modalInstance.dismiss('cancel');
  2006. }
  2007. },
  2008. size: 'sm',
  2009. resolve: {
  2010. api_bpm: function () {
  2011. return api_bpm;
  2012. },
  2013. modelData: function () {
  2014. return model;
  2015. },
  2016. currentUserId: function () {
  2017. return loginUser.id;
  2018. },
  2019. Alert: function () {
  2020. return SweetAlert;
  2021. },
  2022. api_user_data: function () {
  2023. return api_user_data;
  2024. }
  2025. }
  2026. });
  2027. modalInstance.result.then(function (selectedItem) {
  2028. if (selectedItem == 'success') {
  2029. defaultFilterData.assignee = loginUser.id;
  2030. $scope.refreshData('expand-right', defaultFilterData);
  2031. }
  2032. });
  2033. }
  2034. // 转派弹窗
  2035. $scope.rotate = function (model) {
  2036. console.log(model)
  2037. var modalInstance = $modal.open({
  2038. templateUrl: 'assets/views/incident/tpl/rotate.tpl.html',
  2039. controller: function ($scope, $modalInstance, api_bpm, modelData, currentUserId, Alert, api_user_data) {
  2040. console.log(model);
  2041. $scope.roleList = {
  2042. 'idx': 0,
  2043. 'sum': 100,
  2044. 'user': {
  2045. 'roledata': {
  2046. 'rolecode': ''
  2047. },
  2048. 'groupdata': {
  2049. 'id': ''
  2050. },
  2051. 'selectType': 1
  2052. }
  2053. }
  2054. for (var i = 0; i < loginUser.role.length; i++) {
  2055. // console.log(loginUser.role[i])
  2056. if (loginUser.role[i].role == '一线支持人员') {
  2057. $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
  2058. $scope.upRole = loginUser.role[i].role;
  2059. }
  2060. if (loginUser.role[i].role == '二线支持人员') {
  2061. $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
  2062. $scope.upRole = loginUser.role[i].role;
  2063. }
  2064. if (loginUser.role[i].role == '事件经理') {
  2065. $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
  2066. $scope.upRole = loginUser.role[i].role;
  2067. }
  2068. }
  2069. var userId = loginUser.id;
  2070. var taskId = model.taskId;
  2071. var postData = {};
  2072. var formKey = model.formKey;
  2073. var processInstanceId = model.processInstanceId;
  2074. $scope.choosUser = {};
  2075. api_configure_form.renderForm(formKey, userId, processInstanceId).then(function (data) {
  2076. postData = data.model;
  2077. })
  2078. api_user_data.fetchDataList('group', {
  2079. "idx": 0,
  2080. "sum": 100
  2081. }).then(function (data) {
  2082. $scope.group = data.list;
  2083. })
  2084. $scope.onChangeGroup = function (item) {
  2085. $scope.roleList.user.groupdata.id = $scope.choosUser.group.id
  2086. console.log($scope.choosUser);
  2087. if ($scope.choosUser.group) {
  2088. api_user_data.fetchDataList('user', $scope.roleList).then(function (data) {
  2089. console.log(data);
  2090. if (data.list.length == 0) {
  2091. Alert.swal({
  2092. title: "暂无处理人数据",
  2093. text: "该工作组暂无转派对象!",
  2094. type: "error"
  2095. });
  2096. return;
  2097. } else {
  2098. $scope.user = data.list;
  2099. }
  2100. })
  2101. }
  2102. }
  2103. $scope.ok = function () {
  2104. if ($scope.choosUser.handlerUser) {
  2105. postData.handler_code = 'forward';
  2106. postData.incident.handlerUser = $scope.choosUser.handlerUser;
  2107. postData.incident.assignee = postData.assignee = $scope.choosUser.handlerUser.id;
  2108. console.log(postData);
  2109. } else {
  2110. Alert.swal({
  2111. title: "操作失败",
  2112. text: "请选择转派对象信息!",
  2113. type: "error"
  2114. });
  2115. return;
  2116. }
  2117. api_bpm.upgrade(postData, taskId, userId, 'completeTask').then(function (response) {
  2118. console.log(response)
  2119. if (response.status == 200) {
  2120. Alert.swal({
  2121. title: "操作成功!",
  2122. confirmButtonColor: "#007AFF",
  2123. type: "success"
  2124. });
  2125. $modalInstance.close('success');
  2126. } else if (response.status == 500) {
  2127. Alert.swal({
  2128. title: "操作失败",
  2129. text: "该事件已被提取,请刷新页面!",
  2130. type: "error"
  2131. });
  2132. $modalInstance.close('success');
  2133. } else {
  2134. Alert.swal({
  2135. title: "操作失败",
  2136. text: "操作失败, 请稍后再试!",
  2137. type: "error"
  2138. });
  2139. }
  2140. });
  2141. }
  2142. $scope.cancel = function () {
  2143. $modalInstance.dismiss('cancel');
  2144. }
  2145. },
  2146. size: 'sm',
  2147. resolve: {
  2148. api_bpm: function () {
  2149. return api_bpm;
  2150. },
  2151. modelData: function () {
  2152. return model;
  2153. },
  2154. currentUserId: function () {
  2155. return loginUser.id;
  2156. },
  2157. Alert: function () {
  2158. return SweetAlert;
  2159. },
  2160. api_user_data: function () {
  2161. return api_user_data;
  2162. }
  2163. }
  2164. });
  2165. modalInstance.result.then(function (selectedItem) {
  2166. if (selectedItem == 'success') {
  2167. defaultFilterData.assignee = loginUser.id;
  2168. $scope.refreshData('expand-right', defaultFilterData);
  2169. }
  2170. });
  2171. }
  2172. // 指派弹窗baba
  2173. $scope.toAssign = function (model) {
  2174. console.log(model)
  2175. var modalInstance = $modal.open({
  2176. templateUrl: 'assets/views/incident/tpl/toAssign.tpl.html',
  2177. controller: function ($scope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data) {
  2178. console.log(model,loginUser);
  2179. //获取组下面的用户
  2180. $scope.getUsers = function(groupId){
  2181. $scope.user = [];
  2182. var postData = {};
  2183. if(groupId){
  2184. postData = {
  2185. "idx": 0,
  2186. "sum": 100,
  2187. user: {
  2188. groupdata:{id:groupId},
  2189. roledata: { rolecode: "first-line support" },
  2190. roledata2: { rolecode: "second-line support" },
  2191. selectType: "1",
  2192. selectDetails:1
  2193. }
  2194. }
  2195. }else{
  2196. postData = {
  2197. "idx": 0,
  2198. "sum": 100,
  2199. user: {
  2200. roledata: { rolecode: "first-line support" },
  2201. roledata2: { rolecode: "second-line support" },
  2202. selectType: "1",
  2203. selectDetails:1
  2204. }
  2205. }
  2206. }
  2207. api_user_data.fetchDataList('user', postData).then(function (data) {
  2208. $scope.user = data.list;
  2209. })
  2210. }
  2211. $scope.assignUser = null;
  2212. $scope.user = [];
  2213. $scope.group = [];
  2214. $scope.getUsers();
  2215. api_user_data.fetchDataList('group', {
  2216. "idx": 0,
  2217. "sum": 100,
  2218. group: {'selectType':'nouser'}
  2219. }).then(function (data) {
  2220. $scope.group = data.list;
  2221. })
  2222. $scope.onChangeRotateUser = function(item){
  2223. $scope.assignUser = item.id;
  2224. }
  2225. $scope.onChangeRotateGroup = function(item){
  2226. $scope.assignGroup = item.id;
  2227. $scope.getUsers(item.id)
  2228. }
  2229. $scope.ok = function () {
  2230. if (!$scope.assignUser){
  2231. Alert.swal({
  2232. title: "操作失败",
  2233. text: "请选择转派对象信息!",
  2234. type: "error"
  2235. });
  2236. return;
  2237. }
  2238. api_bpm_domain.delegateTask(model.taskId, {assginee:$scope.assignUser}).then(function (response) {
  2239. console.log(response)
  2240. if (response.status == 200) {
  2241. Alert.swal({
  2242. title: "操作成功!",
  2243. confirmButtonColor: "#007AFF",
  2244. type: "success"
  2245. });
  2246. $modalInstance.close('success');
  2247. } else {
  2248. Alert.swal({
  2249. title: "操作失败",
  2250. text: "操作失败, 请稍后再试!",
  2251. type: "error"
  2252. });
  2253. }
  2254. });
  2255. }
  2256. $scope.cancel = function () {
  2257. $modalInstance.dismiss('cancel');
  2258. }
  2259. },
  2260. size: 'sm',
  2261. resolve: {
  2262. api_bpm: function () {
  2263. return api_bpm;
  2264. },
  2265. modelData: function () {
  2266. return model;
  2267. },
  2268. currentUserId: function () {
  2269. return loginUser.id;
  2270. },
  2271. Alert: function () {
  2272. return SweetAlert;
  2273. },
  2274. api_user_data: function () {
  2275. return api_user_data;
  2276. }
  2277. }
  2278. });
  2279. modalInstance.result.then(function (selectedItem) {
  2280. if (selectedItem == 'success') {
  2281. defaultFilterData.assignee = loginUser.id;
  2282. $scope.refreshData('expand-right', defaultFilterData);
  2283. }
  2284. });
  2285. }
  2286. // 删除事件
  2287. $scope.delSj = function(model){
  2288. console.log(model);
  2289. SweetAlert.swal({
  2290. title: "确认删除?",
  2291. text: "删除的数据不可恢复,请确认继续操作!",
  2292. type: "warning",
  2293. showCancelButton: true,
  2294. confirmButtonColor: "#DD6B55",
  2295. confirmButtonText: "继续删除",
  2296. cancelButtonText: "取消操作",
  2297. closeOnConfirm: false,
  2298. closeOnCancel: false
  2299. }, function (isConfirm) {
  2300. if (isConfirm) {
  2301. api_bpm_schedule.del(model.id).then(function (response) {
  2302. if (response.status == 200) {
  2303. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  2304. $scope.refreshData('expand-right', JSON.parse(sessionStorage.getItem("searchincident")));
  2305. } else {
  2306. SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
  2307. }
  2308. });
  2309. } else {
  2310. SweetAlert.swal("操作取消", "数据安全", "error");
  2311. }
  2312. });
  2313. }
  2314. // 新增沟通记录弹窗
  2315. $scope.toHandlerLog = function (model) {
  2316. console.log(model)
  2317. var modalInstance = $modal.open({
  2318. templateUrl: 'assets/views/incident/tpl/toHandlerLog.tpl.html',
  2319. controller: function ($scope, $rootScope, $modalInstance, api_bpm_domain,api_bpm_data, modelData, currentUserId, Alert, api_user_data) {
  2320. $scope.model = model;
  2321. console.log(model,loginUser);
  2322. $scope.handlerLog = '';
  2323. $scope.hdPhone = '';
  2324. $scope.callId = '';
  2325. $scope.user = [];
  2326. $scope.telephone = '';
  2327. $scope.copyTo = function(phone){
  2328. $scope.hdPhone = phone;
  2329. }
  2330. // 测试 start
  2331. // api_bpm_data.getCallRecordId({ano: '1501', bno: '13297968972', agentId: 46}).then(function(response){
  2332. // console.log(response)
  2333. // if (response.status == 200) {
  2334. // $scope.callId = response.data || undefined;
  2335. // } else {
  2336. // $scope.callId = undefined;
  2337. // }
  2338. // });
  2339. // 测试 end
  2340. $scope.dialout = function (teleno) {
  2341. $rootScope.callout = 2;
  2342. if (localStorage.getItem('fenjiNumber')) {
  2343. $rootScope.toggle('off-sidebar');
  2344. }else if(localStorage.getItem('hk_phone')){
  2345. var gid = "@0"
  2346. var telephone = '9' + teleno
  2347. $rootScope.callout = 2;
  2348. if ($rootScope.takes) {
  2349. $rootScope.isMask = true;
  2350. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  2351. console.log(data);
  2352. $rootScope.isMask = false;
  2353. if (data.errno == 0) {
  2354. $rootScope.status = 6;
  2355. $scope.telephone = telephone;
  2356. }else{
  2357. $scope.callId = undefined;
  2358. }
  2359. })
  2360. } else {
  2361. SweetAlert.swal({
  2362. title: "呼叫失败",
  2363. text: "请先签入呼叫中心!",
  2364. type: "error",
  2365. confirmButtonColor: "#DD6B55"
  2366. });
  2367. }
  2368. } else {
  2369. SweetAlert.swal({
  2370. title: "呼叫失败",
  2371. text: "请先签入呼叫中心!",
  2372. type: "error",
  2373. confirmButtonColor: "#DD6B55",
  2374. });
  2375. }
  2376. };
  2377. $scope.ok = function () {
  2378. if (!$scope.handlerLog.trim()){
  2379. Alert.swal({
  2380. title: "操作失败",
  2381. text: "请填写沟通结果!",
  2382. type: "error"
  2383. });
  2384. return;
  2385. }
  2386. api_bpm_data.getCallRecordId({ano: localStorage.getItem('hk_phone'), bno: $scope.telephone, agentId: $rootScope.user.id}).then(function(response){
  2387. console.log(response)
  2388. if (response.status == 200) {
  2389. $scope.callId = response.data || undefined;//获取callId
  2390. } else {
  2391. $scope.callId = undefined;
  2392. }
  2393. api_bpm_data.addData('operationLog',{operationLog:{opType:'handlerLog',opValue:$scope.handlerLog,extra1:model.id, extra2: $scope.callId}}).then(function(response){
  2394. console.log(response)
  2395. if (response.status == 200) {
  2396. Alert.swal({
  2397. title: "操作成功!",
  2398. confirmButtonColor: "#007AFF",
  2399. type: "success"
  2400. });
  2401. $modalInstance.close('success');
  2402. } else {
  2403. Alert.swal({
  2404. title: "操作失败",
  2405. text: "操作失败, 请稍后再试!",
  2406. type: "error"
  2407. });
  2408. }
  2409. });
  2410. });
  2411. }
  2412. $scope.cancel = function () {
  2413. $modalInstance.dismiss('cancel');
  2414. }
  2415. },
  2416. size: 'sm',
  2417. resolve: {
  2418. api_bpm: function () {
  2419. return api_bpm;
  2420. },
  2421. modelData: function () {
  2422. return model;
  2423. },
  2424. currentUserId: function () {
  2425. return loginUser.id;
  2426. },
  2427. Alert: function () {
  2428. return SweetAlert;
  2429. },
  2430. api_user_data: function () {
  2431. return api_user_data;
  2432. }
  2433. }
  2434. });
  2435. modalInstance.result.then(function (selectedItem) {
  2436. if (selectedItem == 'success') {
  2437. defaultFilterData.assignee = loginUser.id;
  2438. $scope.refreshData('expand-right', defaultFilterData);
  2439. }
  2440. });
  2441. }
  2442. // 协同弹窗
  2443. $scope.cooperate = function (model) {
  2444. console.log(model)
  2445. var modalInstance = $modal.open({
  2446. templateUrl: 'assets/views/incident/tpl/cooperate.tpl.html',
  2447. controller: function ($scope, $modalInstance, APIService, modelData, currentUserId, Alert) {
  2448. var receiveTask = function (receive_code, modelData) {
  2449. var data = {
  2450. 'receive_code': receive_code
  2451. };
  2452. if (modelData) {
  2453. return {
  2454. taskId: modelData.taskId,
  2455. data: data
  2456. };
  2457. } else {
  2458. return 'error';
  2459. }
  2460. };
  2461. $scope.title = "提示";
  2462. // $scope.connect = "升级单选组件";
  2463. $scope.ok = function () {
  2464. //接收任务//请求重新指派
  2465. var data = receiveTask($scope.receive_code, modelData);
  2466. APIService.claimAndCompletedTask(data.taskId, {
  2467. userId: currentUserId,
  2468. receive_code: "handler"
  2469. }).then(function (response) {
  2470. if (response.status == 200) {
  2471. Alert.swal({
  2472. title: "操作成功!",
  2473. confirmButtonColor: "#007AFF",
  2474. type: "success"
  2475. });
  2476. $modalInstance.close('success');
  2477. } else if (response.status == 500) {
  2478. Alert.swal({
  2479. title: "操作失败",
  2480. text: "该事件已被提取,请刷新页面!",
  2481. type: "error"
  2482. });
  2483. $modalInstance.close('success');
  2484. } else {
  2485. Alert.swal({
  2486. title: "操作失败",
  2487. text: "操作失败, 请稍后再试!",
  2488. type: "error"
  2489. });
  2490. }
  2491. });
  2492. }
  2493. $scope.cancel = function () {
  2494. $modalInstance.dismiss('cancel');
  2495. }
  2496. },
  2497. size: 'sm',
  2498. resolve: {
  2499. APIService: function () {
  2500. return api_bpm_domain;
  2501. },
  2502. modelData: function () {
  2503. return model;
  2504. },
  2505. currentUserId: function () {
  2506. return loginUser.id;
  2507. },
  2508. Alert: function () {
  2509. return SweetAlert;
  2510. }
  2511. }
  2512. });
  2513. modalInstance.result.then(function (selectedItem) {
  2514. if (selectedItem == 'success') {
  2515. defaultFilterData.assignee = loginUser.id;
  2516. $scope.refreshData('expand-right', defaultFilterData);
  2517. }
  2518. });
  2519. }
  2520. if ($stateParams.model) {
  2521. if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
  2522. $scope.searchType = JSON.parse($stateParams.model).searchType;
  2523. } else {
  2524. $scope.searchType = "all";
  2525. }
  2526. } else {
  2527. $scope.searchType = "all";
  2528. }
  2529. // if (JSON.parse($stateParams.model).searchType) {
  2530. // if ($rootScope.user.group) {
  2531. // var defaultFilterData = {
  2532. // "assignee": $rootScope.user.id,
  2533. // "candidateGroups": loginuserGroup,
  2534. // "searchType": JSON.parse($stateParams.model).searchType,
  2535. // "idx": 0,
  2536. // "sum": mun
  2537. // };
  2538. // } else {
  2539. // var defaultFilterData = {
  2540. // "assignee": $rootScope.user.id,
  2541. // "searchType": JSON.parse($stateParams.model).searchType,
  2542. // "idx": 0,
  2543. // "sum": mun
  2544. // };
  2545. // }
  2546. // } else {
  2547. if ($rootScope.user.group) {
  2548. var defaultFilterData = {
  2549. "assignee": loginUser.id,
  2550. "candidateGroups": loginuserGroup,
  2551. "searchType": "all",
  2552. "idx": 0,
  2553. "sum": mun
  2554. };
  2555. } else {
  2556. var defaultFilterData = {
  2557. "assignee": $rootScope.user.id,
  2558. "searchType": "all",
  2559. "idx": 0,
  2560. "sum": mun
  2561. };
  2562. }
  2563. // }
  2564. // var defaultFilterData = {
  2565. // "assignee":$rootScope.user.id,
  2566. // "candidateGroups":$rootScope.user.group[0].id,
  2567. // "idx":0,
  2568. // "sum":mun
  2569. // };
  2570. if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
  2571. defaultFilterData['searchType'] = $rootScope.search.incident;
  2572. $scope.searchType = $rootScope.search.incident;
  2573. }
  2574. // if ($rootScope['cmdbs'] != 'incident') { $rootScope.idx = 1 }
  2575. // if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
  2576. // $rootScope['cmdbs'] = 'incident';
  2577. // defaultFilterData.idx = $rootScope.idx - 1;
  2578. // } else { $rootScope.cmdbs = ""; }
  2579. $scope.ldloading = {};
  2580. // $scope.Change= function(upTypes){
  2581. // if(angular.isDefined(upTypes)&&upTypes=='upincident'){
  2582. // $state.go('app.problem.incident',{});
  2583. // }
  2584. // else if(angular.isDefined(upTypes)&&upTypes=='upchange'){
  2585. // $state.go('app.change.incident',{});
  2586. // }
  2587. // }
  2588. //事件类型筛选
  2589. console.log($state);
  2590. if($state.params.tab){
  2591. $scope.searchstate = $state.params.tab;
  2592. }else if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).searchType) {
  2593. $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  2594. }else{
  2595. $scope.searchstate = 'all';
  2596. }
  2597. $scope.onChange = function (searchType) {
  2598. if(searchType === 'all_del'){
  2599. var obj = $scope.state.find(function(v){return v.id == 1708});
  2600. $scope.othcode = {state:obj};
  2601. $scope.isDisabledState = true;
  2602. }else{
  2603. $scope.isDisabledState = false;
  2604. }
  2605. $scope.searchstate = searchType;
  2606. $scope.chiceIncident($scope.searchkeys,$scope.othcode.state);
  2607. // console.log(defaultFilterData,'fanbu')
  2608. // if(defaultFilterData.incident){
  2609. // var lsObject = defaultFilterData.incident;
  2610. // }
  2611. // defaultFilterData = $scope.memoryfilterData;
  2612. // defaultFilterData.incident = lsObject;
  2613. // defaultFilterData['searchType'] = searchType;
  2614. // defaultFilterData.assignee = loginUser.id;
  2615. // // -----------seimin-------------
  2616. // if(searchType!=='all'){
  2617. // $scope.searchkeys = {selectType:{}};//seimin
  2618. // }
  2619. // if(searchType!== 'all'&&defaultFilterData.incident&&defaultFilterData.incident.selectType){
  2620. // delete defaultFilterData.incident.selectType;
  2621. // }
  2622. // if(searchType== 'all'){
  2623. // if(!defaultFilterData.incident||!defaultFilterData.incident.selectType){
  2624. // $scope.searchkeys = {selectType:{id:'0',name:'否'}};//seimin
  2625. // }
  2626. // }
  2627. // if(Object.prototype.toString.call(defaultFilterData.incident) == "[object Object]"&&Object.keys(defaultFilterData.incident).length == 0){
  2628. // delete defaultFilterData.incident;
  2629. // }
  2630. // if($scope.othcode.state){
  2631. // if(Object.prototype.toString.call(defaultFilterData.incident) == "[object Object]"){
  2632. // defaultFilterData.incident.statusId = $scope.othcode.state.id;
  2633. // }else{
  2634. // defaultFilterData.incident = {statusId:$scope.othcode.state.id};
  2635. // }
  2636. // }
  2637. // // -----------seimin-------------
  2638. // $scope.refreshData('expand-right', defaultFilterData);
  2639. // $interval.cancel($scope.timer);
  2640. // $scope.timer = $interval(function () {
  2641. // $scope.jry_refresh()
  2642. // }, $rootScope.refreshTime);
  2643. }
  2644. // 是否逾期下拉框选择seimin
  2645. $scope.selectTypeChange = function(){
  2646. console.log($scope.searchkeys.selectType,66666);
  2647. if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
  2648. $scope.searchkeys.selectType = {id:'2',name:'是'};
  2649. // window.sessionStorage.removeItem('isGoyuqi');//seimin
  2650. }
  2651. var ids = $scope.searchkeys.selectType.id
  2652. if(defaultFilterData.incident){
  2653. defaultFilterData.incident.selectType = ids;//seimin
  2654. }else{
  2655. defaultFilterData.incident = {
  2656. selectType:ids
  2657. };
  2658. }
  2659. defaultFilterData.searchType = 'all';
  2660. console.log(defaultFilterData,2222)
  2661. $scope.onChange('all');
  2662. }
  2663. //获取列表数据
  2664. $scope.refreshData = function (style, filterData) {
  2665. console.log(filterData,9090)
  2666. if (filterData && filterData.incident && filterData.incident.area) {
  2667. filterData.incident.place = {
  2668. id: filterData.incident.place ? filterData.incident.place.id : '',
  2669. area: filterData.incident.area
  2670. }
  2671. delete filterData.incident.area
  2672. }
  2673. $scope.ldloading[style.replace('-', '_')] = true;
  2674. if (angular.isUndefined(filterData)) {
  2675. if (sessionStorage.searchincident) {
  2676. filterData = JSON.parse(sessionStorage.getItem("searchincident"));
  2677. if ($scope.searchType) {
  2678. filterData.searchType = $scope.searchType;
  2679. }
  2680. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2681. if($state.params.tab){
  2682. $scope.searchstate = $state.params.tab;
  2683. filterData.searchType = $state.params.tab;
  2684. sessionStorage.setItem('searchincident',JSON.stringify(filterData));
  2685. }else if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).searchType) {
  2686. $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  2687. }else{
  2688. $scope.searchstate = filterData.searchType;
  2689. }
  2690. if($state.params.date == 'today'){
  2691. $scope.othcode = {};
  2692. $scope.searchkeys.acceptDate = new Date();
  2693. $scope.searchkeys.acceptDateEnd = new Date();
  2694. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  2695. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2696. }
  2697. if($state.params.state){
  2698. $scope.searchkeys.acceptDate = null;
  2699. $scope.searchkeys.acceptDateEnd = null;
  2700. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  2701. $scope.othcode = {state:obj};
  2702. filterData.incident = {statusId: $state.params.state};
  2703. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2704. }
  2705. if (filterData.incident && filterData.incident.category) {
  2706. delete filterData.incident.category
  2707. }
  2708. } else {
  2709. filterData = defaultFilterData;
  2710. if ($scope.searchType) {
  2711. filterData.searchType = $scope.searchType;
  2712. if (filterData.searchType == 'overDate') {
  2713. $scope.searchstate = 'overDate';
  2714. }
  2715. }
  2716. if($state.params.tab){
  2717. $scope.searchstate = $state.params.tab;
  2718. filterData.searchType = $state.params.tab;
  2719. sessionStorage.setItem('searchincident',JSON.stringify(filterData));
  2720. }else{
  2721. $scope.searchstate = filterData.searchType;
  2722. }
  2723. if($state.params.date == 'today'){
  2724. $scope.othcode = {};
  2725. $scope.searchkeys.acceptDate = new Date();
  2726. $scope.searchkeys.acceptDateEnd = new Date();
  2727. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  2728. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2729. }
  2730. if($state.params.state){
  2731. $scope.searchkeys.acceptDate = null;
  2732. $scope.searchkeys.acceptDateEnd = null;
  2733. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  2734. $scope.othcode = {state:obj};
  2735. filterData.incident = {statusId: $state.params.state};
  2736. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2737. }
  2738. }
  2739. }
  2740. // if (angular.isDefined($scope.searchTypes)) {
  2741. // $rootScope['search'] = {};
  2742. // filterData['searchType'] = $scope.searchTypes;
  2743. // $rootScope['search']['incident'] = $scope.searchTypes;
  2744. // }
  2745. // if (sessionStorage.idx) {
  2746. // filterData.idx = Number(sessionStorage.idx);
  2747. // $scope.gridOptions.idx = Number(sessionStorage.idx) + 1;
  2748. // }
  2749. console.log(filterData,11111);
  2750. if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
  2751. $scope.searchkeys.selectType = {id:'2',name:'是'};
  2752. if(filterData.incident&&filterData.incident.selectType){
  2753. filterData.incident.selectType = '2';
  2754. }else{
  2755. filterData.incident = {
  2756. selectType : '2'
  2757. }
  2758. }
  2759. window.sessionStorage.removeItem('isGoyuqi');//seimin
  2760. }
  2761. $scope.myData = [];
  2762. sessionStorage['searchincident'] = angular.copy(JSON.stringify(filterData));
  2763. // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2764. //var start = new Date();
  2765. //var sec = $interval(function () {
  2766. //$scope.callsPending++;
  2767. $scope.memoryfilterData = filterData;
  2768. $scope.gridOptions['sum'] = filterData.sum;
  2769. api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
  2770. if (data.data) {
  2771. // if(filterData.searchType == 'all'){
  2772. // //跳到全部seimin
  2773. // $scope.searchstate = 'all';
  2774. // }
  2775. var myData = Restangular.stripRestangular(data);
  2776. var list = [];
  2777. $scope.gridOptions['totalItems'] = myData.resultCount;
  2778. $scope.myData = myData.data;
  2779. for (var i = 0; i < $scope.myData.length; i++) {
  2780. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2781. }
  2782. } else {
  2783. SweetAlert.swal({
  2784. title: "系统错误",
  2785. text: "请稍后再试!",
  2786. type: "error"
  2787. });
  2788. }
  2789. $scope.ldloading[style.replace('-', '_')] = false;
  2790. }, function () {
  2791. $scope.ldloading[style.replace('-', '_')] = false;
  2792. });
  2793. };
  2794. $scope.refreshData2 = function (style, filterData) {
  2795. $scope.ldloading[style.replace('-', '_')] = true;
  2796. if (angular.isUndefined(filterData)) {
  2797. if (sessionStorage.searchincident) {
  2798. filterData = JSON.parse(sessionStorage.getItem("searchincident"));
  2799. if ($scope.searchType) {
  2800. filterData.searchType = $scope.searchType;
  2801. }
  2802. $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2803. // $scope.searchstate = filterData.searchType;
  2804. if($state.params.tab){
  2805. $scope.searchstate = $state.params.tab;
  2806. filterData.searchType = $state.params.tab;
  2807. sessionStorage.setItem('searchincident',JSON.stringify(filterData));
  2808. }else{
  2809. $scope.searchstate = filterData.searchType;
  2810. }
  2811. if($state.params.date == 'today'){
  2812. $scope.othcode = {};
  2813. $scope.searchkeys.acceptDate = new Date();
  2814. $scope.searchkeys.acceptDateEnd = new Date();
  2815. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  2816. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2817. }
  2818. if($state.params.state){
  2819. $scope.searchkeys.acceptDate = null;
  2820. $scope.searchkeys.acceptDateEnd = null;
  2821. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  2822. $scope.othcode = {state:obj};
  2823. filterData.incident = {statusId: $state.params.state};
  2824. sessionStorage.setItem("searchincident",JSON.stringify(filterData));
  2825. }
  2826. if (filterData.incident && filterData.incident.category) {
  2827. delete filterData.incident.category
  2828. }
  2829. } else {
  2830. filterData = defaultFilterData;
  2831. if ($scope.searchType) {
  2832. filterData.searchType = $scope.searchType;
  2833. if (filterData.searchType == 'overDate') {
  2834. $scope.searchstate = 'overDate';
  2835. }
  2836. }
  2837. }
  2838. }
  2839. // if (angular.isDefined($scope.searchTypes)) {
  2840. // $rootScope['search'] = {};
  2841. // filterData['searchType'] = $scope.searchTypes;
  2842. // $rootScope['search']['incident'] = $scope.searchTypes;
  2843. // }
  2844. // if (sessionStorage.idx) {
  2845. // filterData.idx = Number(sessionStorage.idx);
  2846. // $scope.gridOptions.idx = Number(sessionStorage.idx) + 1;
  2847. // }
  2848. // $scope.myData = [];
  2849. sessionStorage['searchincident'] = angular.copy(JSON.stringify(filterData));
  2850. // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
  2851. //var start = new Date();
  2852. //var sec = $interval(function () {
  2853. //$scope.callsPending++;
  2854. $scope.memoryfilterData = filterData;
  2855. $scope.gridOptions['sum'] = filterData.sum;
  2856. api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
  2857. if (data.data) {
  2858. var myData = Restangular.stripRestangular(data);
  2859. var list = [];
  2860. $scope.gridOptions['totalItems'] = myData.resultCount;
  2861. $scope.myData = myData.data;
  2862. for (var i = 0; i < $scope.myData.length; i++) {
  2863. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2864. }
  2865. } else {
  2866. SweetAlert.swal({
  2867. title: "系统错误",
  2868. text: "请稍后再试!",
  2869. type: "error"
  2870. });
  2871. }
  2872. $scope.ldloading[style.replace('-', '_')] = false;
  2873. }, function () {
  2874. $scope.ldloading[style.replace('-', '_')] = false;
  2875. });
  2876. };
  2877. // 进入页面时111
  2878. if(window.sessionStorage.getItem('searchincident')){
  2879. var varLin = JSON.parse(window.sessionStorage.getItem('searchincident'));
  2880. if(varLin.incident&&varLin.incident.selectType){
  2881. if(varLin.incident.selectType == '2'){
  2882. console.log(defaultFilterData)
  2883. $scope.searchkeys.selectType = {id:'2',name:'是'};
  2884. }else if(varLin.incident.selectType == '0'){
  2885. console.log(defaultFilterData)
  2886. $scope.searchkeys.selectType = {id:'0',name:'否'};
  2887. }
  2888. }
  2889. }
  2890. if(window.sessionStorage.getItem('isGoyuqi') === 'yes'){
  2891. $scope.selectTypeChange();
  2892. }else{
  2893. if(sessionStorage.getItem("searchincident")){
  2894. var ss = JSON.parse(sessionStorage.getItem("searchincident"));
  2895. delete ss.incident;
  2896. sessionStorage.setItem("searchincident",JSON.stringify(ss));
  2897. }
  2898. $scope.refreshData('expand-right');
  2899. }
  2900. $scope.timer = $interval(function () {
  2901. $scope.jry_refresh()
  2902. }, $rootScope.refreshTime);
  2903. $scope.$on('$destroy', function () {
  2904. $interval.cancel($scope.timer)
  2905. });
  2906. }]);
  2907. //操作按钮权限控制
  2908. app.controller('IncidentOperCtrl', ['$rootScope', '$http', '$scope', '$modal', '$state', 'api_bpm_data', function ($rootScope, $http, $scope, $modal, $state, api_bpm_data) {
  2909. // console.log('$rootScope.user3='+JSON.stringify($scope.item));
  2910. // console.log($scope.item)
  2911. var loginUser = $rootScope.user;
  2912. console.log(loginUser.role)
  2913. $scope.chuli = false;
  2914. $scope.qiangdan = false;
  2915. $scope.dayin = false;
  2916. $scope.huifang = false;
  2917. // $scope.assign = false;
  2918. $scope.delFlag = false;
  2919. $scope.editFlag = false;//编辑
  2920. $scope.assignFlag = false;//指派
  2921. // if(loginUser.role.length){
  2922. // $scope.assign = loginUser.role.some(function(v){
  2923. // return v.rolecode === "incident-category-manager"||v.rolecode === 'incident manager';
  2924. // })
  2925. // }
  2926. for (var i = 0; i < loginUser.menu.length; i++) {
  2927. if (loginUser.menu[i].link == "shijianliebiao_chuli") {
  2928. $scope.chuli = true
  2929. }
  2930. if (loginUser.menu[i].link == "shijianliebiao_qiangdan") {
  2931. $scope.qiangdan = true
  2932. }
  2933. if (loginUser.menu[i].link == "shijianliebiao_dayin") {
  2934. $scope.dayin = true
  2935. }
  2936. if (loginUser.menu[i].link == "shijianliebiao_huifang") {
  2937. $scope.huifang = true
  2938. }
  2939. if (loginUser.menu[i].link == "shijianliebiao_del") {
  2940. $scope.delFlag = true
  2941. }
  2942. if (loginUser.menu[i].link == "shijianliebiao_edit") {
  2943. $scope.editFlag = true
  2944. }
  2945. if (loginUser.menu[i].link == "shijianliebiao_assign") {
  2946. $scope.assignFlag = true
  2947. }
  2948. }
  2949. $scope.up = true;
  2950. $scope.fuwutaiRenYuan = false;//服务台人员
  2951. for (var i = 0; i < $rootScope.user.role.length; i++) {
  2952. // console.log($rootScope.user.role[i])
  2953. if ($rootScope.user.role[i].role == '事件经理') {
  2954. $scope.up = false;
  2955. }
  2956. if ($rootScope.user.role[i].id == 29701) {
  2957. $scope.fuwutaiRenYuan = true;
  2958. }
  2959. }
  2960. if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  2961. // 当前登陆人和当前处理人相同,并且状态非已关闭
  2962. if ($rootScope.user.id == $scope.item.handlerUser.id && $scope.item.state.id != 1546) {
  2963. $scope.item.chaozuoPower = true;
  2964. // if ($scope.item.state.id == 1544) {
  2965. // $scope.item.coordination = true;
  2966. // }
  2967. }
  2968. }
  2969. $rootScope.callid = $scope.item.callID;
  2970. if ($scope.item.callID) {
  2971. $scope.item.listen = true;
  2972. } else {
  2973. $scope.item.listen = false;
  2974. }
  2975. // 抢单操作权限
  2976. // if ($scope.item.state.id != 1546 && $scope.item.handlerUser == null) {
  2977. // angular.forEach($rootScope.user.group, function (item) {
  2978. // if (item.id == $scope.item.candidateGroups) {
  2979. // $scope.item.tiquPower = true;
  2980. // }
  2981. // })
  2982. $rootScope.user.group.forEach(function (item, v) {
  2983. if (item.id == $scope.item.candidateGroups) {
  2984. $scope.item.tiquPower = true;
  2985. }
  2986. })
  2987. // }
  2988. //修改页面显示判断
  2989. $scope.jry_modify = function (item) {
  2990. // console.log(item)
  2991. // var jry_role = false;
  2992. // for (var i = 0; i < $rootScope.user.role.length; i++) {
  2993. // if ($rootScope.user.role[i].rolecode == "call center") {
  2994. // jry_role = true
  2995. // }
  2996. // }
  2997. var arrFlag = ['pending','handler'];
  2998. var stateFlag = arrFlag.includes(item.state.value)
  2999. // return jry_role && stateFlag;
  3000. return stateFlag && $scope.editFlag;
  3001. }
  3002. // 回访操作权限
  3003. for (var obj in $rootScope.user.role) {
  3004. // console.log($rootScope.user.role[obj].rolecode)
  3005. if ($rootScope.user.role[obj].rolecode == 'call center') {
  3006. if ($scope.item.state.id == 1546) {
  3007. $scope.item.huifang = true;
  3008. } else {
  3009. // $scope.item.xiugai = true;
  3010. }
  3011. }
  3012. }
  3013. // 评价操作权限
  3014. $scope.jry_evaluateShow = function () {
  3015. var jry_role = false;
  3016. for (var i = 0; i < $rootScope.user.role.length; i++) {
  3017. if ($rootScope.user.role[i].role == "事件经理" && $rootScope.user.role[i].rolecode == "incident manager") {
  3018. jry_role = true
  3019. }
  3020. }
  3021. // if($scope.item.groupScore!=undefined){
  3022. if ($scope.item.state.id == 1546 && jry_role && $scope.item.groupScore.id == 220) {
  3023. return true
  3024. } else {
  3025. return false
  3026. }
  3027. // }
  3028. }
  3029. $scope.coordination = function () {
  3030. $scope.colobject.grid.appScope.coordination($scope.item);
  3031. }
  3032. $scope.look = function () {
  3033. //$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: $scope.item.id});
  3034. $scope.colobject.grid.appScope.lookFunction($scope.item);
  3035. // console.log('$scope.item='+JSON.stringify($scope.item));
  3036. //$scope.doEdit($scope.item.id);
  3037. }
  3038. $scope.edit = function () {
  3039. // console.log($scope.item)
  3040. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  3041. // console.log('$scope.item='+JSON.stringify($scope.item));
  3042. // $scope.doEdit($scope.item.id);
  3043. }
  3044. $scope.configuration = function () {
  3045. console.log($scope.item);
  3046. $scope.colobject.grid.appScope.configuration($scope.item)
  3047. }
  3048. $scope.changeCenter = function () {
  3049. $scope.colobject.grid.appScope.changeClick($scope.item);
  3050. }
  3051. $scope.visit = function () {
  3052. $scope.colobject.grid.appScope.visit($scope.item);
  3053. }
  3054. $scope.print = function () { //print
  3055. api_bpm_data.fetchData('incident', $scope.item.id).then(function (res) {
  3056. $scope.colobject.grid.appScope.open(res.data);
  3057. })
  3058. // $scope.colobject.grid.appScope.open($scope.item);
  3059. }
  3060. // 升级
  3061. $scope.upgrade = function () { //print
  3062. $scope.colobject.grid.appScope.upgrade($scope.item);
  3063. // $scope.doEdit($scope.item.id);
  3064. }
  3065. // 转派
  3066. $scope.rotate = function () { //print
  3067. $scope.colobject.grid.appScope.rotate($scope.item);
  3068. // $scope.doEdit($scope.item.id);
  3069. }
  3070. // 指派
  3071. $scope.toAssign = function () { //print
  3072. $scope.colobject.grid.appScope.toAssign($scope.item);
  3073. // $scope.doEdit($scope.item.id);
  3074. }
  3075. // 删除事件
  3076. $scope.delSj = function () {
  3077. $scope.colobject.grid.appScope.delSj($scope.item);
  3078. }
  3079. // 新增沟通记录
  3080. $scope.toHandlerLog = function () { //print
  3081. $scope.colobject.grid.appScope.toHandlerLog($scope.item);
  3082. // $scope.doEdit($scope.item.id);
  3083. }
  3084. // 协同
  3085. $scope.cooperate = function () { //print
  3086. $scope.colobject.grid.appScope.cooperate($scope.item);
  3087. // $scope.doEdit($scope.item.id);
  3088. }
  3089. // 升级问题
  3090. $scope.problem = function () {
  3091. console.log($scope.item)
  3092. console.log($scope.colobject.grid.appScope)
  3093. $scope.colobject.grid.appScope.problem($scope.item)
  3094. }
  3095. $scope.record = function () { //record
  3096. $scope.colobject.grid.appScope.play($scope.item);
  3097. // $scope.doEdit($scope.item.id);
  3098. }
  3099. $scope.handler = function () {
  3100. $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
  3101. $scope.doComment($scope.item.id);
  3102. }
  3103. $scope.follow = function () {
  3104. $scope.colobject.grid.appScope.followFunction($scope.item);
  3105. }
  3106. //查看
  3107. $scope.toDetail = function (data) {
  3108. //console.log('data='+JSON.stringify(data));
  3109. console.log(data,$rootScope.isFuwutai);
  3110. if($rootScope.isFuwutai){
  3111. //角色是服务台人员
  3112. $state.go('app.incident.detail', {
  3113. formKey: 'incident_back',
  3114. pdKey: 'incident',
  3115. dataId: data.id,
  3116. taskId: data.taskId,
  3117. processInstanceId: data.processInstanceId
  3118. });
  3119. }else{
  3120. window.open(location.origin+'/#/app/incident/detail/incident_back/incident/'+data.id+'/'+data.taskId+'/'+data.processInstanceId+'//');
  3121. }
  3122. };
  3123. // $scope.play = function() {
  3124. // // console.log($scope.item.callID)
  3125. // var modalInstance = $modal.open({
  3126. // templateUrl: 'assets/views/incident/tpl/audio.html',
  3127. // controller: function($scope, $modalInstance,$sce){
  3128. // $scope.data={
  3129. // "name":"视频",
  3130. // "url":"http://192.168.3.69:8088/recording/recording?callID="+$rootScope.callid
  3131. // };
  3132. // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
  3133. // // $scope.audiourl={url:$sce.trustAsResourceUrl("http://192.168.3.69:8088/recording/recording?callID=218147232")};
  3134. // $scope.cancel = function() {
  3135. // $modalInstance.dismiss('cancel');
  3136. // };
  3137. // $modalInstance.close();
  3138. // }
  3139. // });
  3140. // };
  3141. }]);
  3142. //操作按钮
  3143. app.directive('incidentoperator', function () {
  3144. return {
  3145. restrict: 'E',
  3146. scope: {
  3147. item: '=',
  3148. colobject: '='
  3149. },
  3150. controller: 'IncidentOperCtrl',
  3151. template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  3152. // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>'+
  3153. '<a ng-click="toDetail(item)" class="bianjifont" >查看</a>' +
  3154. '<a ng-click="edit()" ng-show="{{item.chaozuoPower&&chuli}}" class="bianjifont">处理</a>' +
  3155. '<a ng-click="handler()" ng-show="{{item.state.id != 1546 &&!item.handlerUser&&item.tiquPower&&qiangdan}}" class="bianjifont" >抢单</a>' +
  3156. '<a ng-click="visit()" ng-show="{{item.huifang&&huifang}}" class="bianjifont">回访</a>' +
  3157. '<a ng-click="changeCenter()" ng-show="jry_modify(item)" class="luyinfont">编辑</a>' +
  3158. '<a ng-click="toAssign()" ng-show="{{(item.state.id==1543||item.state.id==1544)&&assignFlag&&item.assignee}}" class="assign" >指派</a>' +
  3159. '<a ng-click="toHandlerLog()" ng-show="{{item.state.id==1544}}" class="assign" >新增沟通记录</a>' +
  3160. '<a ng-click="delSj()" ng-show="{{delFlag&&item.state.value!== \'deleted\'}}" class="assign" >删除</a>' +
  3161. '<a ng-click="print()" ng-show="dayin" class="bianjifont" >打印</a>' +
  3162. // '<a ng-click="jry_evaluate()" ng-show="jry_evaluateShow()" class="luyinfont" >评价</a>' +
  3163. '<a ng-click="record()" ng-show="{{item.callID}}" class="luyinfont" >录音</a>' +
  3164. // '<a ng-click="rotate()" ng-show="{{item.state.id==4}}" class="rotate" >转派</a>' +
  3165. // '<a ng-click="upgrade()" ng-show="{{up&&item.state.id==4&&item.currentRole!=' + "'incident manager'" + '}}" class="upgrade" >升级</a>' +
  3166. // '<a ng-click="problem()" ng-show="{{item.state.id==5&&item.currentRole!=' + "'incident manager'" + '}}" class="upgrade" >问题升级</a>' +
  3167. // '<a ng-click="configuration()" ng-show="{{item.state.id==5}}" class="bianjifont">变更升级</a>' +
  3168. // '<a ng-click="cooperate()" ng-show="{{item.state.id==4}}" class="cooperate" >协同</a>' +
  3169. // '<a ng-click="coordination()" ng-show="{{item.coordination}}" tooltip="添加协同人" tooltip-placement="left"><i class="icon iconfont icon-tianjiarenyuan adduserfont"></i></a>' +
  3170. // '<a class="ui-grid-cell-contents" ng-click="grid.appScope.open(row.entity)" tooltip="打印" tooltip-placement="left"><i class="ti-printer"></i></a>'+
  3171. // '<a ng-click="grid.appScope.play(row.entity)"ng-if="row.entity.callID" tooltip="播放录音" tooltip-placement="left"><i class="ti-microphone"></i></a>'+
  3172. // '<a ng-click="follow()" tooltip="状态跟踪" tooltip-placement="left"><i class="fa fa-location-arrow"></i></a>'+
  3173. '</div></div>'
  3174. };
  3175. });