incidentCtrl.js 144 KB

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