incidentCtrl.js 96 KB

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