incidentCtrl.js 112 KB

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