incidentCtrl.js 142 KB

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