incidentCtrl.js 99 KB

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