incidentCtrl.js 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402
  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 = {deleted:false};
  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: 0,
  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. filterData.incident = {acceptDate:moment().format('YYYY-MM-DD 00:00:00'),acceptDateEnd:moment().format('YYYY-MM-DD 23:59:59')};
  2053. }else{
  2054. $scope.searchkeys.acceptDate = undefined;
  2055. $scope.searchkeys.acceptDateEnd = undefined;
  2056. }
  2057. if($state.params.state){
  2058. var obj = $scope.state.find(function(v){return $state.params.state == v.id});
  2059. $scope.othcode = {state:obj};
  2060. filterData.incident = {statusId: $state.params.state};
  2061. }
  2062. }
  2063. }
  2064. $scope.myData = [];
  2065. $scope.memoryfilterData = filterData;
  2066. $scope.gridOptions['sum'] = filterData.sum;
  2067. // 请求参数调整
  2068. if(!filterData.incident){
  2069. filterData.incident = {};
  2070. }
  2071. if($scope.searchstate === 'all' || $scope.searchstate === 'callback'){
  2072. if($rootScope.user.duty){
  2073. // 当前的所属责任科室
  2074. filterData.incident.duty = $rootScope.user.duty;
  2075. }else if($rootScope.user.branch){
  2076. // 当前的所属院区
  2077. filterData.incident.branch = $rootScope.user.branch.id;
  2078. }
  2079. }else{
  2080. delete filterData.incident.duty;
  2081. delete filterData.incident.branch;
  2082. }
  2083. filterData.incident.queryTask = $scope.searchstate;
  2084. filterData.incident.assignee = loginUser.id;
  2085. if($scope.searchstate === 'todo' || $scope.searchstate === 'owns'){
  2086. filterData.incident.candidateGroups = loginuserGroup;
  2087. }else{
  2088. delete filterData.incident.candidateGroups;
  2089. }
  2090. // 调用接口-查列表
  2091. api_user_data.fetchDataList('incident', filterData).then(function (data) {
  2092. if (data.list) {
  2093. var myData = Restangular.stripRestangular(data);
  2094. $scope.gridOptions['totalItems'] = myData.totalNum;
  2095. $scope.myData = myData.list;
  2096. for (var i = 0; i < $scope.myData.length; i++) {
  2097. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  2098. }
  2099. } else {
  2100. SweetAlert.swal({
  2101. title: "系统错误",
  2102. text: "请稍后再试!",
  2103. type: "error"
  2104. });
  2105. }
  2106. $scope.ldloading[style.replace('-', '_')] = false;
  2107. }, function () {
  2108. $scope.ldloading[style.replace('-', '_')] = false;
  2109. });
  2110. // 调用接口-查数量
  2111. let numPostData = {
  2112. tabs: $scope.tabs.map(v => v.key).toString(),
  2113. assignee: loginUser.id,
  2114. candidateGroups: loginuserGroup,
  2115. }
  2116. if($rootScope.user.duty){
  2117. // 当前的所属责任科室
  2118. numPostData.dutyId = $rootScope.user.duty.id;
  2119. }else if($rootScope.user.branch){
  2120. // 当前的所属院区
  2121. numPostData.branchId = $rootScope.user.branch.id;
  2122. }
  2123. api_flow.count(numPostData).then(function (data) {
  2124. if (data.state == 200) {
  2125. let myData = data.data[0] || {};
  2126. $scope.tabs.forEach(v => {
  2127. v.num = myData[v.key];
  2128. })
  2129. } else {
  2130. SweetAlert.swal({
  2131. title: "系统错误",
  2132. text: "请稍后再试!",
  2133. type: "error"
  2134. });
  2135. }
  2136. $scope.ldloading[style.replace('-', '_')] = false;
  2137. }, function () {
  2138. $scope.ldloading[style.replace('-', '_')] = false;
  2139. });
  2140. }, 500);
  2141. // 进入页面时
  2142. $scope.getIncidentStatus();
  2143. $scope.timer = $interval(function () {
  2144. $scope.jry_refresh()
  2145. }, $rootScope.refreshTime);
  2146. $scope.$on('$destroy', function () {
  2147. $interval.cancel($scope.timer)
  2148. });
  2149. }]);
  2150. //操作按钮权限控制
  2151. app.controller('IncidentOperCtrl', ['$rootScope', '$scope', '$state', function ($rootScope, $scope, $state) {
  2152. var loginUser = $rootScope.user;
  2153. $scope.user = $rootScope.user;
  2154. $scope.chuli = false;
  2155. $scope.qiangdan = false;
  2156. $scope.huifang = false;
  2157. $scope.delFlag = false;
  2158. $scope.storageFlag = false;
  2159. $scope.editFlag = false;//编辑
  2160. $scope.assignFlag = false;//指派
  2161. $scope.transferFlag = false;//转派
  2162. $scope.shijianliebiao_duty = false;//设置责任科室
  2163. for (var i = 0; i < loginUser.menu.length; i++) {
  2164. if (loginUser.menu[i].link == "shijianliebiao_chuli") {
  2165. $scope.chuli = true
  2166. }
  2167. if (loginUser.menu[i].link == "shijianliebiao_qiangdan") {
  2168. $scope.qiangdan = true
  2169. }
  2170. if (loginUser.menu[i].link == "shijianliebiao_huifang") {
  2171. $scope.huifang = true
  2172. }
  2173. if (loginUser.menu[i].link == "shijianliebiao_del") {
  2174. $scope.delFlag = true
  2175. }
  2176. if (loginUser.menu[i].link == "shijianliebiao_build") {
  2177. $scope.storageFlag = true
  2178. }
  2179. if (loginUser.menu[i].link == "shijianliebiao_edit") {
  2180. $scope.editFlag = true
  2181. }
  2182. if (loginUser.menu[i].link == "shijianliebiao_assign") {
  2183. $scope.assignFlag = true
  2184. }
  2185. if (loginUser.menu[i].link == "shijianliebiao_transfer") {
  2186. $scope.transferFlag = true
  2187. }
  2188. if (loginUser.menu[i].link == "shijianliebiao_duty") {
  2189. $scope.shijianliebiao_duty = true
  2190. }
  2191. }
  2192. $scope.up = true;
  2193. $scope.fuwutaiRenYuan = false;//服务台人员
  2194. for (var i = 0; i < $rootScope.user.role.length; i++) {
  2195. if ($rootScope.user.role[i].role == '事件经理') {
  2196. $scope.up = false;
  2197. }
  2198. if ($rootScope.user.role[i].id == 29701) {
  2199. $scope.fuwutaiRenYuan = true;
  2200. }
  2201. }
  2202. $rootScope.callid = $scope.item.callID;
  2203. if ($scope.item.callID) {
  2204. $scope.item.listen = true;
  2205. } else {
  2206. $scope.item.listen = false;
  2207. }
  2208. $rootScope.user.group.forEach(function (item, v) {
  2209. if($scope.item.currentLog){
  2210. if (item.id == $scope.item.currentLog.groupId) {
  2211. $scope.item.tiquPower = true;
  2212. }
  2213. }
  2214. })
  2215. //修改页面显示判断
  2216. $scope.jry_modify = function (item) {
  2217. var arrFlag = ['pending','handler'];
  2218. var stateFlag = arrFlag.includes(item.state.value)
  2219. return stateFlag && $scope.editFlag;
  2220. }
  2221. // 回访操作权限
  2222. for (var obj in $rootScope.user.role) {
  2223. if ($rootScope.user.role[obj].rolecode == 'call center') {
  2224. if ($scope.item.state.id == 1546) {
  2225. $scope.item.huifang = true;
  2226. } else {}
  2227. }
  2228. }
  2229. $scope.edit = function () {
  2230. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  2231. }
  2232. $scope.changeCenter = function () {
  2233. $scope.colobject.grid.appScope.changeClick($scope.item);
  2234. }
  2235. $scope.visit = function () {
  2236. $scope.colobject.grid.appScope.visit($scope.item);
  2237. }
  2238. // 指派
  2239. $scope.toAssign = function () {
  2240. $scope.colobject.grid.appScope.toAssign($scope.item);
  2241. }
  2242. // 转派
  2243. $scope.toTransfer = function () {
  2244. $scope.colobject.grid.appScope.toTransfer($scope.item);
  2245. }
  2246. // 删除事件
  2247. $scope.delSj = function () {
  2248. $scope.colobject.grid.appScope.delSj($scope.item);
  2249. }
  2250. // 继续创建
  2251. $scope.storageSj = function () {
  2252. $scope.colobject.grid.appScope.storageSj($scope.item);
  2253. }
  2254. // 新增延期处理
  2255. $scope.toHandlerLog = function () {
  2256. $scope.colobject.grid.appScope.toHandlerLog($scope.item);
  2257. }
  2258. // 设置责任科室
  2259. $scope.setDuty = function () {
  2260. $scope.colobject.grid.appScope.setDuty($scope.item);
  2261. }
  2262. $scope.play = function () { //record
  2263. $scope.colobject.grid.appScope.play($scope.item);
  2264. }
  2265. $scope.handler = function () {
  2266. $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
  2267. }
  2268. //查看
  2269. $scope.toDetail = function (data) {
  2270. console.log(data,$rootScope.isFuwutai);
  2271. if($rootScope.isFuwutai){
  2272. //角色是服务台人员
  2273. $state.go('app.incident.incidentDetail', {
  2274. id: data.id,
  2275. });
  2276. }else{
  2277. window.open(location.origin+'/#/app/incident/incidentDetail/'+data.id);
  2278. }
  2279. };
  2280. }]);
  2281. //操作按钮
  2282. app.directive('incidentoperator', function () {
  2283. return {
  2284. restrict: 'E',
  2285. scope: {
  2286. item: '=',
  2287. colobject: '='
  2288. },
  2289. controller: 'IncidentOperCtrl',
  2290. template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" style="text-align:left;">' +
  2291. '<a ng-click="toDetail(item)" class="bianjifont" >查看</a>' +
  2292. // '<a ng-click="changeCenter()" ng-show="jry_modify(item)" class="luyinfont">编辑</a>' +
  2293. '<a ng-click="delSj()" ng-show="{{delFlag && item.state.value !== \'deleted\'}}" class="assign" >删除</a>' +
  2294. '<a ng-click="storageSj()" ng-show="{{storageFlag && item.state.value === \'storage\'}}" class="assign" >继续创建</a><br>' +
  2295. '<a ng-click="edit()" ng-show="{{item.state.value == \'handler\' && item.handlingPersonnelUser && item.handlingPersonnelUser.id == user.id && chuli}}" class="bianjifont">处理</a>' +
  2296. '<a ng-click="handler()" ng-show="{{item.state.value == \'pending\' && ((item.currentLog && item.currentLog.workerId == user.id) || item.tiquPower) && qiangdan}}" class="bianjifont" >接单</a>' +
  2297. '<a ng-click="visit()" ng-show="{{item.state.value == \'close\' && huifang}}" class="bianjifont">回访</a>' +
  2298. '<a ng-click="toAssign()" ng-show="{{(item.state.value == \'pending\' || item.state.value == \'handler\' || item.state.value == \'reassign\') && assignFlag}}" class="assign" >指派</a>' +
  2299. '<a ng-click="toTransfer()" ng-show="{{item.state.value == \'handler\' && item.handlingPersonnelUser && item.handlingPersonnelUser.id == user.id && !assignFlag && transferFlag}}" class="assign" >转派</a>' +
  2300. '<a ng-click="toHandlerLog()" ng-show="{{item.state.value == \'handler\'}}" class="assign" >延期处理</a>' +
  2301. '<a ng-click="setDuty()" ng-show="{{shijianliebiao_duty && (item.state.value == \'resolved\' || item.state.value == \'close\')}}" class="assign" >设置责任科室</a>' +
  2302. '</div></div>'
  2303. };
  2304. });