incidentCtrl.js 141 KB

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