incidentCtrl.js 133 KB

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