incidentCtrl.js 99 KB

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