incidentCtrl.js 137 KB

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