incidentCtrl.js 143 KB

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