incidentCtrl.js 95 KB

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