incidentCtrl.js 99 KB

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