incidentCtrl.js 112 KB

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