incidentCtrl.js 97 KB

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