incidentCtrl.js 96 KB

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