incidentCtrl.js 111 KB

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