incidentCtrl.js 133 KB

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