1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434 |
- 'use strict';
- 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) {
- //保存报修主体
- $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
- $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
- $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
- $rootScope.isFuwutai = JSON.parse(localStorage.getItem("isFuwutai")) ? true : false;
- // ----------------分割线 start-----------------
- console.log($state)
- // 显示隐藏
- $scope.isDeployment = false;
- $scope.deploymentHandler = function(){
- $scope.isDeployment = !$scope.isDeployment;
- console.log($('#filterSearch .incidentsearch:gt(7)'));
- if($scope.isDeployment){
- $('#filterSearch .incidentsearch:gt(7)').css('display', 'inline-block');
- }else{
- $('#filterSearch .incidentsearch:gt(7)').css('display', 'none');
- }
- }
- // -----------------分割线 end----------------
- // 是否逾期seimin
- $scope.selectType = [
- { id: '2', name: '是' },
- { id: '0', name: '否' }
- ];
- $scope.tabs = [
- // {key: 'all', value: '全部事件', num: ''},
- {key: 'todo', value: '待我接单', num: ''},
- {key: 'doing', value: '待我处理', num: ''},
- // {key: 'reassign', value: '重新指派', num: ''},
- // {key: 'callback', value: '待我回访', num: ''},
- {key: 'resolve', value: '由我解决', num: ''},
- {key: 'owns', value: '与我关联', num: ''},
- {key: 'storage', value: '暂存', num: ''},
- ]
- // /是否逾期
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.myData = [];
- var loginUser = $rootScope.user;
- $scope.allFlag = false;//全部事件
- $scope.daochu = false;//导出
- $scope.huifang = false;//回访
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "shijianliebiao_all") {
- $scope.allFlag = true;
- $scope.tabs.splice(0, 0 , {key: 'all', value: '全部事件', num: ''});
- }
- if (loginUser.menu[i].link == "shijianliebiao_huifang") {
- $scope.huifang = true;
- let index = $scope.tabs.findIndex(v => v.key == 'resolve');
- $scope.tabs.splice(index, 0 , {key: 'callback', value: '待我回访', num: ''});
- }
- if (loginUser.menu[i].link == "shijianliebiao_reassign") {
- $scope.huifang = true;
- let index = $scope.tabs.findIndex(v => v.key == 'doing');
- $scope.tabs.splice(index + 1, 0 , {key: 'reassign', value: '重新指派', num: ''});
- }
- if (loginUser.menu[i].link == "shijianliebiao_daochu") {
- $scope.daochu = true
- }
- }
- var loginuserGroup = "";
- for (var i = 0; i < $rootScope.user.group.length; i++) {
- if (i == 0) {
- loginuserGroup = $rootScope.user.group[i].id;
- } else {
- loginuserGroup = loginuserGroup + "," + $rootScope.user.group[i].id;
- }
- }
- // 处理人,受理人,转派人
- var pdKey = $state.current.pdKey;
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.rowHeight = 54;
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableSelectAll = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.enableSorting = true;
- $scope.gridOptions.useExternalSorting = true;
- $scope.gridOptions.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- var mun = $scope.gridOptions.paginationPageSize;
- $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>";
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.transferColor = function (item) {
- var color = "icon iconfont icon-zhengchang greenfont";
- if (item.colourInfo) {
- if (item.colourInfo.id == 1583) {
- color = "icon iconfont icon-yiyuqi redfont";
- } else if (item.colourInfo.id == 1584) {
- color = "iconfont icon-yuqixinxiu orangefont";
- }
- }
- return color;
- }
- $scope.transfertip = function (item) {
- var tip = "正常";
- if (item.colourInfo) {
- if (item.colourInfo.id == 1583) {
- tip = "已逾期";
- } else if (item.colourInfo.id == 1584) {
- tip = "即将逾期";
- } else if (item.colourInfo.id == 1586) {
- tip = "正常";
- }
- }
- return tip;
- }
- $scope.transferstatus = function (item) {
- var statecolor = "#fc4c58";
- if (item.id == 2) { //待处理
- statecolor = "#fc4c58";
- } else if (item.id == 7) { //待审核
- statecolor = "#fcb44c";
- } else if (item.id == 3) { //请求重新指派
- statecolor = "#ebf902";
- } else if (item.id == 4) { //处理中
- statecolor = "#0aa5f5";
- } else if (item.id == 5) { //已解决
- statecolor = "#2edbb8";
- } else if (item.id == 6) { //已关闭
- statecolor = "#bbbbbb";
- }
- return statecolor;
- }
- if($scope.repairMain.valueconfig == 1){//报修人
- $scope.gridOptions.columnDefs = [
- {
- name: 'id',
- displayName: '',
- width: 35,
- cellTemplate: '<div>' +
- '<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>' +
- '</div>'
- },
- {
- name: 'item',
- displayName: '序号',
- width: 45,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: 'incidentsign',
- displayName: '事件单号',
- width: 120,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.incidentsign}}</div>' +
- '</div>'
- },
- {
- name: 'requester.name',
- displayName: '报修人',
- width: '6%',
- minWidth: '90',
- enableSorting: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" >{{row.entity.requester.name}}</div>' +
- '</div>'
- },
- {
- name: 'requester.account',
- displayName: '学工号',
- width: '6%',
- minWidth: '90',
- enableSorting: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" >{{row.entity.requester.account}}</div>' +
- '</div>'
- },
- {
- name: 'contactsInformation',
- displayName: '联系电话',
- width: '105',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.contactsInformation}}</div>' +
- '</div>'
- },
- {
- name: 'category',
- displayName: '故障现象',
- width: '10%',
- enableSorting: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.category.category}}</div>' +
- '</div>'
- },
- {
- name: 'houseNumber',
- displayName: '区域地点',
- width: '14%',
- enableFiltering: false,
- cellTemplate: '<div><div class="ui-grid-cell-contents" ng-bind-html="grid.appScope.areaplace(row.entity)"></div></div>'
- },
- {
- name: 'acceptUser.name',
- displayName: '受理人',
- width: '7%',
- minWidth: '80',
- enableSorting: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" >{{row.entity.acceptUser.name}}</div>' +
- '</div>'
- },
- {
- name: 'acceptDate',
- displayName: '登记时间',
- width: '10%',
- minWidth: '140',
- enableFiltering: false,
- cellTemplate: '<div><div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.acceptDate)}}</div></div>'
- },
- {
- name: 'groupORHandlerUser',
- displayName: '处理人/组',
- width: '10%',
- enableFiltering: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">' +
- '{{row.entity.groupORHandlerUser}}</div>' +
- '</div>'
- },
- {
- name: 'state.name',
- displayName: '状态',
- width: '7%',
- minWidth: '70',
- enableSorting: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" >{{row.entity.state.name}}</div>' +
- '</div>'
- },
- {
- name: '操作',
- enableSorting: false,
- width: 500,
- cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
- enableFiltering: false
- },
- ];
- if($scope.wxIncidentWithCmdb==1){
- let index = $scope.gridOptions.columnDefs.findIndex(v=>v.name == 'contactsInformation');
- $scope.gridOptions.columnDefs.splice(index,0,{
- name: 'assetId',
- displayName: '资产',
- width: 120
- },)
- }
- }else if($scope.repairMain.valueconfig == 2){//报修科室
- $scope.gridOptions.columnDefs = [
- {
- name: 'id',
- displayName: '',
- width: 35,
- cellTemplate: '<div style="width: 100%;">' +
- '<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>' +
- '</div>'
- },
- {
- name: 'row1',
- displayName: '序号',
- width: 45,
- cellTemplate: '<div style="width: 100%;">' +
- '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
- '</div>'
- },
- {
- name: 'row2',
- displayName: '单号|报修科室',
- width: 150,
- cellTemplate: '<div style="width: 100%;">' +
- '<div class="ui-grid-cell-contents">{{row.entity.incidentsign || "无"}}<br>{{row.entity.department ? row.entity.department.dept : "无"}}</div>' +
- '</div>'
- },
- {
- name: 'row3',
- displayName: '报修人|来电电话',
- width: 150,
- cellTemplate: '<div style="width: 100%;">' +
- '<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>' +
- '</div>'
- },
- {
- name: 'row5',
- displayName: '故障现象|区域地点',
- width: 350,
- cellTemplate: '<div style="width: 100%;">' +
- '<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>' +
- '</div>'
- },
- {
- name: 'row6',
- displayName: '受理人|处理人/组',
- width: 150,
- cellTemplate: '<div style="width: 100%;">' +
- '<div class="ui-grid-cell-contents">{{row.entity.acceptUser ? row.entity.acceptUser.name : "无"}}<br>{{row.entity.groupORHandlerUser || "无"}}</div>' +
- '</div>'
- },
- {
- name: 'row7',
- displayName: '登记时间|接单时间',
- width: 150,
- cellTemplate: '<div style="width: 100%;">' +
- '<div class="ui-grid-cell-contents">{{grid.appScope.transferTime(row.entity.acceptDate)}}<br>{{grid.appScope.transferTime(row.entity.responseHandleTime)}}</div>' +
- '</div>'
- },
- {
- name: 'row9',
- displayName: '状态|解决时间',
- width: 150,
- cellTemplate: '<div style="width: 100%;">' +
- '<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>' +
- '</div>'
- },
- {
- name: 'row10',
- displayName: '最近维修记录',
- width: 140,
- cellTemplate: '<div style="width: 100%;">' +
- '<div class="ui-grid-cell-contents" ng-bind-html="grid.appScope.transferHandlerLog(row.entity.currentLog)"></div>' +
- '</div>'
- },
- {
- name: '操作',
- enableSorting: false,
- width: 196,
- cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
- enableFiltering: false
- },
- ];
- }
- $scope.transferTime = function (time) {
- if(time){
- return moment(time).format('YYYY-MM-DD HH:mm');
- }else{
- return '无';
- }
- }
- $scope.transferHandlerLog = function (currentLog) {
- if(!currentLog){
- return '无';
- }
- currentLog = angular.copy(currentLog);
- if(currentLog.extra1DTO && currentLog.extra2 && currentLog.startTime){
- return currentLog.extra1DTO.name+"<br>"+ moment(currentLog.startTime).add(+currentLog.extra2, 'days').format('MM月DD日前完成');
- }else{
- return '无';
- }
- }
- $scope.endOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.startOpened = false;
- $scope.endOpened = !$scope.endOpened;
- };
- $scope.startOpen = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.endOpened = false;
- $scope.startOpened = !$scope.startOpened;
- };
- $scope.othcode = {};
- $scope.searchkeys = {};
- // 是否选择已删除
- $scope.selectDeleted = function(e){
- console.log($scope.searchkeys.deleteFlag);
- $scope.chiceIncident($scope.searchkeys,$scope.othcode.state);
- }
- $scope.my_data = [];
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.my_tree = {};
- $scope.select_treedata = [];
- // 报修科室
- $scope.getDept = function (key) {
- var postData = {
- "idx": 0,
- "sum": 10
- }
- if (key) {
- postData.department = { dept: key }
- }
- api_user_data.fetchDataList('department', postData).then(function (response) {
- if (response) {
- if (response.status = 200) {
- $scope.department = response.list;
- }
- }
- })
- }
- $scope.getDept();
- //树形图
- // 将故障现象搜索结果返回的数据整理成children模式
- function transform(nodes) {
- var treeConverter = {
- result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
- attributeName: 'id', //节点唯一标识符
- needFind: true, //是否查询节点在result中已经存在,为了优化效率
- transform: function (node) { //转化递归函数,参数:一个待插入节点
- if (node.parent != null) { //该节点有父节点
- var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
- if (this.needFind) {
- for (var i = 0; i < newNode.children.length; i++) { //查找要插入的node子节点是否在newNode这个父节点中存在
- if (newNode.children[i][this.attributeName] === node[this.attributeName]) {
- return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- }
- }
- }
- this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
- // delete node.parent; //删除该节点的parent属性,如果有的话
- node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
- newNode.children.push(node); //将该node节点push进newNode的子节点数组中
- return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
- } else if (node.parent == null) { //该叶节点没有父节点,即为根节点
- // delete node.parent; //删除该节点的parent属性,如果有的话
- if (this.result == null) { //根节点不存在
- node.children = []; //给该节点增加children:[]属性
- return this.result = node; //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- } else {
- node.children = [];
- // 顶级去重
- for (var i = 0; i < this.result.children.length; i++) {
- if (this.result.children[i][this.attributeName] === node[this.attributeName]) {
- return this.result.children[i];
- }
- }
- this.result.children.push(node)
- return node // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
- }
- }
- },
- getWhole: function (nodes, attributeName) { //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
- var _node = {};
- _node.children = [];
- this.result = _node; //重置根节点
- this.attributeName = attributeName == null ? 'id' : attributeName; //唯一标识符默认为“id”
- nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
- nodes.forEach(item => { //循环调用转化方法
- this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
- this.transform(item);
- })
- return this.result; //返回根节点
- }
- }
- var result = treeConverter.getWhole(nodes); //调用
- return result;
- }
- $scope.my_tree = {};
- $rootScope.bala1 = $scope.try_async_load = function (s, fn) {
- if (s) {
- var filterKeyword = s.filterKeyword;
- }
- var postData = {
- "idx": 0,
- "sum": 1000,
- "incidentcategory": {},
- }
- if (filterKeyword) {
- postData.incidentcategory = { selectType: "pinyin_qs", category: filterKeyword }
- }
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- postData.incidentcategory.duty = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- postData.incidentcategory.branch = $rootScope.user.branch.id;
- }
- $scope.my_data = [];
- $scope.doing_async = true;
- api_bpm_data.fetchDataList('incidentcategory', postData).then(function (response) {
- if (response.status == 200) {
- var data = response.list;
- if (filterKeyword) {
- data.forEach(e => {
- e.isExpanded = true;
- })
- var li = transform(data).children;
- console.log(li)
- fn(li)
- return;
- } else {
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- object.parent = data[i].parent;
- object.category = data[i].category;
- object.isExpanded = true;
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.select_treedata = angular.copy($scope.my_data);
- }
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- };
- $scope.my_data = [];
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.try_async_load();
- // 故障现象
- $scope.onFilterCallback = function (item) {
- console.log(item);
- if (item.item) {
- $scope.searchkeys.levelCategory = item = undefined;
- } else {
- $scope.searchkeys.levelCategory = item;
- }
- }
- //状态
- $scope.state = [];
- $scope.getIncidentStatus = function(){
- api_wechatfile.getDictionary({
- "type": "list",
- "key": "incident_status"
- }).then(function (response) {
- $scope.state = response || [];
- if(window.sessionStorage.getItem('isGoyuqi') === 'yes'){
- $scope.selectTypeChange(true);
- }else{
- $scope.refreshData('expand-right', undefined, true);
- }
- })
- }
- $scope.clear = function () {
- $scope.searchkeys = {};
- $scope.othcode = {};
- $scope.try_async_load();
- defaultFilterData = {
- idx: 0,
- sum: mun
- }
- $scope.refreshData('expand-right');
- $interval.cancel($scope.timer);
- $scope.timer = $interval(function () {
- $scope.jry_refresh()
- }, $rootScope.refreshTime);
- }
- // 刷新
- $scope.jry_refresh = function () {
- var fildata = defaultFilterData;
- if (fildata.incident && fildata.incident.category) {
- delete fildata.incident.category
- }
- fildata.idx = $scope.jry_idx;
- fildata.sum = $scope.jry_sum;
- $scope.refreshData('expand-right', fildata);
- console.log($scope.cifilter_classic);
- }
- // 搜索
- $scope.chiceIncident = function (item, stateid, isInit) {
- if (stateid && stateid.id) {
- item.statusId = stateid.id;
- } else {
- item.statusId = undefined;
- }
- console.log(item)
- var fildata = defaultFilterData;
- if (!fildata.incident) {
- fildata['incident'] = {};
- }
- if (item.acceptDate) {
- item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD 00:00:00');
- }
- if (item.acceptDateEnd) {
- item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD 23:59:59')
- }
- var transitiondata = angular.copy(item);
- angular.extend(fildata.incident, transitiondata)
- $scope.memoryfilterData = fildata;
- console.log(fildata,78777);
- if($scope.searchstate === 'all'){
- if(fildata.incident&&fildata.incident.selectType){
- fildata.incident.selectType = fildata.incident.selectType.id;
- }
- }else{
- if(fildata.incident&&fildata.incident.selectType){
- delete fildata.incident.selectType;
- }
- }
- // /seimin
- $scope.refreshData('expand-right', fildata, isInit);
- $interval.cancel($scope.timer);
- $scope.timer = $interval(function () {
- $scope.jry_refresh()
- }, $rootScope.refreshTime);
- }
- //区域地点过滤
- api_user_data.fetchDataList('area', {
- "idx": 0,
- "sum": 1000
- }).then(function (response) {
- if (response) {
- if (response.status = 200) {
- $scope.outarea = response.list;
- }
- }
- })
- //报修人
- var getRequester = function () {
- api_user_data.fetchDataList('user', {
- idx: 0,
- sum: 100,
- user:{
- engineer: undefined,
- }
- }).then(function (data) {
- // console.log(data);
- $scope.requester = data.list
- });
- }
- getRequester();
- //受理人,处理人
- var getUser = function (fieldatas, it) {
- api_user_data.fetchDataList('user', fieldatas).then(function (data) {
- if (it == 1) {
- $scope.acceptUser = data.list;
- } else if (it == 2) {
- $scope.handlingPersonnelUser = data.list;
- }
- });
- }
- //受理人过滤
- $scope.onChangeacceptUser = function (key) {
- console.log(key)
- var filuser = {
- "idx": 0,
- "sum": 10,
- "user": {
- "name": key,
- 'selectType': "pinyin_qs",
- engineer: 1,
- }
- }
- getUser(filuser, 1);
- }
- //处理人过滤
- $scope.onChangehandling = function (key) {
- var filuser = {
- "idx": 0,
- "sum": 10,
- "user": {
- "name": key,
- 'selectType': "pinyin_qs",
- engineer: 1,
- }
- }
- getUser(filuser, 2);
- }
- //报修科室过滤
- $scope.onChangeDept = function (key) {
- $scope.getDept(key)
- }
- //地点区域过滤
- $scope.onChangearea = function (data) {
- delete $scope.searchkeys.place;
- if ($scope.memoryfilterData.incident) {
- delete $scope.memoryfilterData.incident.place;
- }
- var fildata = {
- "idx": 0,
- "sum": 1000,
- "place": {
- area: {
- id: data.area.id
- }
- }
- };
- api_user_data.fetchDataList('place', fildata).then(function (response) {
- if (response) {
- if (response.status = 200) {
- $scope.outplace = response.list;
- }
- }
- })
- };
- $scope.starttime = function (data) {
- return moment(new Date(data)).format('YYYY-MM-DD')
- }
- $scope.overtime = function (data) {
- return moment(new Date(data)).format('YYYY-MM-DD HH:mm')
- }
- $scope.areaplace = function (data) {
- var str = '';
- str += '<strong>' + data.branchName + '</strong>';
- str += (data.place ? (data.place.area ? data.place.area.area : '') : '');
- str += (data.place ? (data.place.place ? data.place.place : '') : '');
- str += (data.houseNumber ? data.houseNumber : '');
- return str || '无';
- }
- //录音
- $scope.play = function (data) {
- console.log(data.callID)
- var modalInstance = $modal.open({
- backdrop: "static",
- templateUrl: 'assets/views/incident/tpl/audio.html',
- controller: function ($rootScope, $scope, $modalInstance, $sce, $http, api_bpm_data) {
- // $rootScope.setbusy();
- $scope.datasurl = "";
- api_bpm_data.fetchDataList("callrecord", {idx: 0, sum: 1, callrecord: {callAccept: data.callID}}).then(function(data) {
- if(data.status == 200){
- data.list = data.list || [];
- if(data.list.length){
- $scope.audioUrl = $sce.trustAsResourceUrl(callIp+data.list[0].recordingFileName);
- }
- }
- });
- $scope.download = function (contentId, filename) {
- $http({
- url: "http://" + $scope.datasurl,
- method: 'GET',
- headers: {
- 'Content-type': 'application/octet-stream',
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/octet-stream'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // console.log(data);
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- $modalInstance.close();
- },
- });
- modalInstance.result.then(function (result) {}, function (reason) {});
- };
- //列表排序
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- var index = 0;
- var oldheader = {};
- gridApi.grid.sortColumn = function (gridApi) {
- if (oldheader.field) {
- if (oldheader.field == gridApi.field) {
- } else {
- index = 0;
- }
- }
- index++;
- oldheader = gridApi;
- var fildata = $scope.memoryfilterData;
- if (index % 3 == 0) {
- delete $scope.memoryfilterData.incident;
- fildata = $scope.memoryfilterData;
- } else if (index % 3 == 1) {
- if (fildata.incident) {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata.incident, {
- "sort": gridApi.field
- });
- } else {
- angular.extend(fildata.incident, {
- "sort": gridApi.field + " desc , _incident.acceptDate"
- });
- }
- } else {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata, {
- 'incident': {
- "sort": gridApi.field
- }
- });
- } else {
- angular.extend(fildata, {
- 'incident': {
- "sort": gridApi.field + " desc , _incident.acceptDate"
- }
- });
- }
- }
- } else if (index % 3 == 2) {
- if (fildata.incident) {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata.incident, {
- "sort": gridApi.field,
- "order": "asc"
- });
- } else {
- angular.extend(fildata.incident, {
- "sort": gridApi.field + " asc , _incident.acceptDate"
- });
- }
- } else {
- if (gridApi.field == "acceptDate") {
- angular.extend(fildata, {
- 'incident': {
- "sort": gridApi.field,
- "order": "asc"
- }
- });
- } else {
- angular.extend(fildata.incident, {
- "sort": gridApi.field + " asc , _incident.acceptDate"
- });
- }
- }
- }
- $scope.refreshData('expand-right', fildata);
- }
- $scope.jry_idx = 0;
- $scope.jry_sum = 10;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- $scope.jry_idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.jry_sum = pageSize;
- });
- $scope.Change = function (upTypes) {
- if (angular.isDefined($scope.selected.items)) {
- if (angular.isDefined(upTypes) && upTypes == 'upincident') {
- var data = {
- cancelUrl: 'app.incident.list',
- model: {
- problem: {
- title: $scope.selected.items.title,
- des: $scope.selected.items.description,
- proposePerson: $scope.selected.items.handlerUser,
- source: {
- id: 1,
- code: 1,
- name: ' 事件 '
- },
- incident: $scope.selected.items
- }
- }
- }
- $state.go('app.problem.incident', {
- pdKey: 'incident',
- dataId: $scope.selected.items.id,
- processInstanceId: $scope.selected.items.processInstanceId,
- 'model': JSON.stringify(data)
- });
- } else if (angular.isDefined(upTypes) && upTypes == 'upchange') {
- var data = {
- cancelUrl: 'app.incident.list',
- model: {
- change: {
- title: $scope.selected.items.title,
- description: $scope.selected.items.description,
- requestingPerson: $scope.selected.items.handlerUser,
- source: {
- id: 1,
- code: 1,
- name: ' 事件 '
- },
- incident: $scope.selected.items
- }
- }
- }
- // var data={cancelUrl:'app.incident.list'}
- $state.go('app.change.incident', {
- pdKey: 'incident',
- dataId: $scope.selected.items.id,
- processInstanceId: $scope.selected.items.processInstanceId,
- 'model': JSON.stringify(data)
- });
- }
- }
- }
- $scope.selected = {
- items: []
- }
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- if ($rootScope.user.group) {
- var filtersData = {
- idx: 0,
- sum: mun
- };
- } else {
- var filtersData = {
- idx: 0,
- sum: mun
- };
- }
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- filtersData = $scope.memoryfilterData
- if (angular.isUndefined(filtersData['incident'])) {
- filtersData['incident'] = {};
- }
- if (item.field == 'department.dept') {
- filtersData['incident']['department'] = {};
- filtersData.incident.department['department'] = item.filters[0].term;
- } else if (item.field == 'handlingPersonnelUser.name') {
- filtersData['incident']['handlingPersonnelUser'] = {};
- filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
- } else if (item.field == 'requester.account') {
- filtersData['incident']['requester'] = {};
- filtersData.incident.requester['account'] = item.filters[0].term;
- } else if (item.field == 'acceptUser.name') {
- filtersData['incident']['acceptUser'] = {};
- filtersData.incident.acceptUser['name'] = item.filters[0].term;
- } else {
- filtersData['incident'][item.field] = item.filters[0].term;
- }
- }
- }
- });
- filtersData.idx = 0;
- $scope.memoryfilterData = filtersData;
- $scope.refreshData('expand-right', filtersData);
- });
- };
- //处理
- $scope.selectRowFunction = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/incident/tpl/doing.tpl.html',
- controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
- console.log(model,loginUser);
- $scope.model = model;
- $scope.postData = {
- handleCategory: undefined,
- closecode: undefined,
- handleDescription: '',
- synergetic: [],
- }
- $scope.incidentHandleCategoryList = [];
- $scope.incidentClosecodeList = [];
- $scope.synergeticList = [];
- // 获取处理方式
- $scope.getIncidentHandleCategory = function(){
- api_wechatfile.getDictionary({"key":"incident_handleCategory","type":"list"}).then(function (data) {
- $scope.incidentHandleCategoryList = data || [];
- })
- }
- // 获取关闭代码
- $scope.getIncidentClosecode = function(){
- api_wechatfile.getDictionary({"key":"incident_closecode","type":"list"}).then(function (data) {
- $scope.incidentClosecodeList = data || [];
- })
- }
- // 获取协同人
- $scope.getSynergeticList = function(keyword = ''){
- let postData = {
- "idx":0,
- "sum":10,
- "user":{
- currentDuty: model.duty ? model.duty.id : undefined,
- name: keyword,
- selectType: "pinyin_qs",
- engineer: 1,
- }
- };
- api_simple.fetchDataList("user", postData).then(result => {
- if(result.status == 200){
- $scope.synergeticList = result.list || [];
- }else{
- $scope.synergeticList = [];
- }
- })
- }
- // 初始化
- $scope.getIncidentHandleCategory();
- $scope.getIncidentClosecode();
- $scope.getSynergeticList();
- $scope.ok = function () {
- if (!$scope.postData.handleCategory){
- Alert.swal({
- title: "操作失败",
- text: "请选择处理方式!",
- type: "error"
- });
- return;
- }
- if ($scope.model.category.hasSimple != 1 &&!$scope.postData.closecode){
- Alert.swal({
- title: "操作失败",
- text: "请选择关闭代码!",
- type: "error"
- });
- return;
- }
- if ($scope.model.category.hasSimple != 1 &&!$scope.postData.handleDescription){
- Alert.swal({
- title: "操作失败",
- text: "请填写处理方案!",
- type: "error"
- });
- return;
- }
- let postData = {incident: {...model, ...{
- handleCategory: $scope.postData.handleCategory,
- closecode: $scope.postData.closecode,
- handleDescription: $scope.postData.handleDescription,
- synergetic: $scope.postData.synergetic.length ? $scope.postData.synergetic : undefined,
- }}};
- $rootScope.isMask = true;
- api_flow.accept("doing", postData).then(function (response) {
- console.log(response)
- $rootScope.isMask = false;
- if (response.state == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- };
- //修改
- $scope.changeClick = function (data) {
- $state.go('app.incident.detail', {
- formKey: 'incident_change',
- pdKey: 'incident',
- dataId: data.id,
- taskId: data.taskId,
- processInstanceId: data.processInstanceId
- });
- };
- //回访
- $scope.visit = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/incident/tpl/callback.tpl.html',
- controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
- console.log(model,loginUser);
- $scope.model = model;
- $scope.postData = {
- degree: undefined,
- visitRemarks: '',
- }
- $scope.degreeList = [];
- // 获取满意度评价
- $scope.getDegree = function(){
- api_wechatfile.getDictionary({"key":"incident_degree","type":"list"}).then(function (data) {
- $scope.degreeList = data || [];
- })
- }
- // 初始化
- $scope.getDegree();
- $scope.ok = function () {
- if (!$scope.postData.degree){
- Alert.swal({
- title: "操作失败",
- text: "请选择满意度评价!",
- type: "error"
- });
- return;
- }
- let postData = {incident: {...model, ...{
- degree: $scope.postData.degree,
- visitRemarks: $scope.postData.visitRemarks,
- }}};
- $rootScope.isMask = true;
- api_flow.accept("callback", postData).then(function (response) {
- console.log(response)
- $rootScope.isMask = false;
- if (response.state == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- };
- //导出
- $scope.export = function () {
- console.log($scope.memoryfilterData)
- var filadata = angular.copy($scope.memoryfilterData);
- filadata.sum = 10000;
- console.log($scope.filadata)
- $http({
- url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
- method: 'POST',
- data: JSON.stringify(filadata),
- headers: {
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- var file = new Blob([data], {
- type: 'application/vnd.ms-excel'
- });
- //trick to download store a file having its URL
- var fileURL = URL.createObjectURL(file);
- var a = document.createElement('a');
- a.href = fileURL;
- a.target = '_blank';
- a.download = '工单列表.xls';
- document.body.appendChild(a);
- a.click();
- }).error(function (data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- console.log(data);
- });
- }
- //接单
- $scope.acceptTaskAction = function (model) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
- controller: function ($scope, $modalInstance, modelData, currentUserId, Alert) {
- $scope.title = "提示";
- $scope.connect = "确认接单?";
- $scope.ok = function () {
- console.log(model);
- $rootScope.isMask = true;
- api_flow.accept("receive", {incident: model}).then(function (response) {
- $rootScope.isMask = false;
- if (response.state == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 指派弹窗
- $scope.toAssign = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/incident/tpl/toAssign.tpl.html',
- controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
- console.log(model,loginUser);
- //获取组下面的用户
- $scope.getUsers = function(groupId){
- $scope.user = [];
- var postData = {};
- if(groupId){
- postData = {
- "idx": 0,
- "sum": 100,
- user: {
- groupdata:{id:groupId},
- roledata: { rolecode: "first-line support" },
- roledata2: { rolecode: "second-line support" },
- selectType: "1",
- selectDetails:1,
- simple: true,
- }
- }
- }else{
- postData = {
- "idx": 0,
- "sum": 100,
- user: {
- roledata: { rolecode: "first-line support" },
- roledata2: { rolecode: "second-line support" },
- selectType: "1",
- selectDetails:1,
- simple: true,
- engineer: 1,
- }
- }
- }
- api_user_data.fetchDataList('user', postData).then(function (data) {
- $scope.user = data.list;
- })
- }
- $scope.assign = {
- branch:undefined,
- duty:undefined,
- user:undefined,
- group:undefined,
- isRadioUser: 0,
- }
- $scope.hospitalList = [];
- $scope.dutyDeptList = [];
- $scope.user = [];
- $scope.group = [];
- $scope.isShowRadioUser = false;
- // 修改是否指派到人
- $scope.changeRadioUser = function(){
- $scope.assign.user = undefined;
- }
- // 获取院区
- $scope.getHospitals = function(){
- //跨科室转派
- api_user_data.fetchDataList('branch', {
- "idx": 0,
- "sum": 100
- }).then(function (data) {
- if(data.status == 200){
- $scope.hospitalList = data.list;
- if($scope.assign.duty){
- $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $scope.assign.duty.branch);
- }else{
- if($rootScope.user.duty){
- // 当前的所属责任科室
- $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
- $scope.assign.duty = $rootScope.user.duty;
- $scope.changeDuty();
- }else if($rootScope.user.branch){
- // 当前的所属院区
- $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
- }
- }
- }else{
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- })
- }
- $scope.getHospitals();
- // 修改院区
- $scope.changeBranch = function(keyword){
- if(keyword === undefined){
- $scope.assign.duty = undefined;
- $scope.dutyDeptList = [];
- $scope.assign.group = undefined;
- $scope.group = [];
- $scope.assign.user = undefined;
- $scope.user = [];
- }
- if(!$scope.assign.branch){
- $scope.dutyDeptList = [];
- return;
- }
- api_user_data.fetchDataList('dutyDepartment', {
- "idx": 0,
- "sum": 100,
- "dutyDepartment":{
- branch:$scope.assign.branch.id,
- dept:keyword,
- selectType: "pinyin_qs"
- }
- }).then(function (data) {
- if(data.status == 200){
- $scope.dutyDeptList = data.list;
- }else{
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- })
- }
- // 修改责任科室
- $scope.changeDuty = function(keyword){
- if(keyword === undefined){
- $scope.assign.user = undefined;
- $scope.user = [];
- $scope.assign.group = undefined;
- $scope.group = [];
- }
- api_user_data.fetchDataList('group', {
- "idx": 0,
- "sum": 9999,
- "group":{
- duty:$scope.assign.duty,
- selectType: "nouser"
- }
- }).then(function (data) {
- if(data.status == 200){
- $scope.group = data.list;
- }else{
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- })
- }
- $scope.changeGroup = function(item){
- // $scope.assign.group = item.id;
- $scope.assign.user = undefined;
- $scope.user = [];
- $scope.getUsers(item.id)
- }
- $scope.ok = function () {
- if ($scope.assign.isRadioUser == 1 && !$scope.assign.user){
- Alert.swal({
- title: "操作失败",
- text: "请选择转派对象信息!",
- type: "error"
- });
- return;
- }
- if ($scope.assign.isRadioUser == 0 && !$scope.assign.group){
- Alert.swal({
- title: "操作失败",
- text: "请选择工作组!",
- type: "error"
- });
- return;
- }
- let postData = {};
- if($scope.assign.user && $scope.assign.user.id){
- // 派人
- postData ={ incident: {...model, ...{assignee: $scope.assign.user.id}} };
- } else if($scope.assign.group && $scope.assign.group.id){
- // 派组
- postData ={ incident: {...model, ...{candidateGroups: $scope.assign.group.id}} };
- }
- $rootScope.isMask = true;
- api_flow.accept("assign", postData).then(function (response) {
- console.log(response)
- $rootScope.isMask = false;
- if (response.state == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 转派弹窗
- $scope.toTransfer = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/incident/tpl/toTransfer.tpl.html',
- controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
- console.log(model,loginUser);
- $scope.assign = {
- duty:model.duty,
- user:undefined,
- group:undefined,
- isRadioGroup: 0,
- }
- $scope.user = [];
- $scope.group = [];
- //获取责任科室下面的用户
- $scope.getUsers = function(){
- $scope.user = [];
- var postData = {
- "idx": 0,
- "sum": 9999,
- user: {
- currentDuty: $scope.assign.duty.id,
- roledata: { rolecode: "first-line support" },
- roledata2: { rolecode: "second-line support" },
- selectType: "1",
- selectDetails:1,
- simple: true,
- engineer: 1,
- }
- }
- api_user_data.fetchDataList('user', postData).then(function (data) {
- $scope.user = data.list;
- })
- }
- $scope.getUsers();
- //获取责任科室下面的组
- $scope.getGroups = function(){
- $scope.group = [];
- var postData = {
- "idx": 0,
- "sum": 9999,
- group: {
- duty: $scope.assign.duty,
- selectType: "nouser",
- }
- }
- api_user_data.fetchDataList('group', postData).then(function (data) {
- $scope.group = data.list;
- })
- }
- $scope.getGroups();
- // 修改是否转派到组
- $scope.changeRadioGroup = function(){
- $scope.assign.group = undefined;
- $scope.assign.user = undefined;
- }
- $scope.ok = function () {
- if ($scope.assign.isRadioGroup == 0 && !$scope.assign.user){
- Alert.swal({
- title: "操作失败",
- text: "请选择转派对象信息!",
- type: "error"
- });
- return;
- }
- if ($scope.assign.isRadioGroup == 1 && !$scope.assign.group){
- Alert.swal({
- title: "操作失败",
- text: "请选择工作组!",
- type: "error"
- });
- return;
- }
- let postData = {};
- if($scope.assign.user && $scope.assign.user.id){
- // 派人
- postData ={ incident: {...model, ...{assignee: $scope.assign.user.id}} };
- } else if($scope.assign.group && $scope.assign.group.id){
- // 派组
- postData ={ incident: {...model, ...{candidateGroups: $scope.assign.group.id}} };
- }
- $rootScope.isMask = true;
- api_flow.accept("redeploy", postData).then(function (response) {
- console.log(response)
- $rootScope.isMask = false;
- if (response.state == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 删除事件
- $scope.delSj = function(model){
- console.log(model);
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- api_bpm_schedule.del(model.id).then(function (response) {
- if (response.status == 200) {
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- $scope.refreshData('expand-right');
- } else {
- SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
- }
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- }
- // 继续创建
- $scope.storageSj = function(model){
- console.log(model);
- $rootScope.newOrder({incident: model});
- }
- // 新增延期处理弹窗
- $scope.toHandlerLog = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/incident/tpl/toHandlerLog.tpl.html',
- controller: function ($scope, $modalInstance, api_bpm_domain,api_bpm_data, modelData, currentUserId, Alert, api_user_data,api_statistic) {
- console.log(model,loginUser);
- $scope.f = {
- maintenanceMode: '',
- estimatedNumberOfDays: ''
- }
- $scope.handlerLog = '';
- $scope.user = [];
- $scope.logs = [];
- $scope.modes = [];
- $scope.getModes=function(){
- var data={
- "idx":0,
- "sum":999,
- dictionary:{key:'repair_type'}
- }
- api_statistic.tableData(data,"dictionary").then(function(res){
- $scope.modes=res.list
- })
- }
- $scope.getModes();
- $scope.getLogs=function(){
- var data={
- "idx":0,
- "sum":999,
- dictionary:{key:'processingLog'}
- }
- api_statistic.tableData(data,"dictionary").then(function(res){
- $scope.logs=res.list
- })
- }
- $scope.getLogs();
- $scope.copyTo = function(value){
- $scope.handlerLog += value;
- }
- $scope.ok = function () {
- if (!$scope.f.maintenanceMode){
- Alert.swal({
- title: "操作失败",
- text: "请选择延期原因!",
- type: "error"
- });
- return;
- }
- if (!$scope.f.estimatedNumberOfDays){
- Alert.swal({
- title: "操作失败",
- text: "请选择延期天数!",
- type: "error"
- });
- return;
- }
- if (!$scope.handlerLog.trim()){
- Alert.swal({
- title: "操作失败",
- text: "请填写延期说明!",
- type: "error"
- });
- return;
- }
- $rootScope.isMask = true;
- api_flow.accept("overtime", {
- incident: {
- ...model,
- ...{
- currentLog: {
- remark: $scope.handlerLog,
- extra1: $scope.f.maintenanceMode.id,
- extra2: $scope.f.estimatedNumberOfDays,
- }
- }
- }
- }).then(function(response){
- console.log(response)
- $rootScope.isMask = false;
- if (response.state == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'lg',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- },
- api_statistic: function () {
- return api_statistic;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 设置责任科室
- $scope.setDuty = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- backdrop: false,
- templateUrl: 'assets/views/incident/tpl/setDuty.tpl.html',
- controller: function ($scope,$rootScope, $modalInstance, api_bpm_domain, modelData, currentUserId, Alert, api_user_data,api_category) {
- console.log(model,loginUser);
- $scope.assign = {
- branch:undefined,
- duty:undefined,
- }
- $scope.hospitalList = [];
- $scope.dutyDeptList = [];
- // 获取院区
- $scope.getHospitals = function(){
- //跨科室转派
- api_user_data.fetchDataList('branch', {
- "idx": 0,
- "sum": 100
- }).then(function (data) {
- if(data.status == 200){
- $scope.hospitalList = data.list;
- if($scope.assign.duty){
- $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $scope.assign.duty.branch);
- }else{
- if($rootScope.user.duty){
- // 当前的所属责任科室
- $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
- $scope.assign.duty = $rootScope.user.duty;
- }else if($rootScope.user.branch){
- // 当前的所属院区
- $scope.assign.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
- }
- }
- }else{
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- })
- }
- $scope.getHospitals();
- // 修改院区
- $scope.changeBranch = function(keyword){
- if(keyword === undefined){
- $scope.assign.duty = undefined;
- $scope.dutyDeptList = [];
- }
- if(!$scope.assign.branch){
- $scope.dutyDeptList = [];
- return;
- }
- api_user_data.fetchDataList('dutyDepartment', {
- "idx": 0,
- "sum": 100,
- "dutyDepartment":{
- branch:$scope.assign.branch.id,
- dept:keyword,
- selectType: "pinyin_qs"
- }
- }).then(function (data) {
- if(data.status == 200){
- $scope.dutyDeptList = data.list;
- }else{
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- })
- }
- $scope.ok = function () {
- if (!$scope.assign.duty){
- Alert.swal({
- title: "操作失败",
- text: "请选择责任科室!",
- type: "error"
- });
- return;
- }
- $rootScope.isMask = true;
- api_bpm_domain.changeIncidentDuty({orderId: model.id, dutyId: $scope.assign.duty.id}).then(function (response) {
- console.log(response)
- $rootScope.isMask = false;
- if (response.status == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- api_bpm: function () {
- return api_bpm;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- if ($stateParams.model) {
- if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
- $scope.searchstate = JSON.parse($stateParams.model).searchType;
- } else {
- $scope.searchstate = "todo";
- }
- } else {
- $scope.searchstate = "todo";
- }
- if ($rootScope.user.group) {
- var defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- } else {
- var defaultFilterData = {
- "idx": 0,
- "sum": mun
- };
- }
- if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
- $scope.searchstate = $rootScope.search.incident;
- }
- $scope.ldloading = {};
- //事件类型筛选
- console.log($state);
- if($state.params.tab){
- $scope.searchstate = $state.params.tab;
- }else{
- $scope.searchstate = 'todo';
- }
- $scope.onChange = function (searchstate, isInit) {
- $scope.isDisabledState = false;
- $scope.searchstate = searchstate;
- $scope.chiceIncident($scope.searchkeys,$scope.othcode.state, isInit);
- }
- // 是否逾期下拉框选择
- $scope.selectTypeChange = function(isInit){
- console.log($scope.searchkeys.selectType,66666);
- if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
- $scope.searchkeys.selectType = {id:'2',name:'是'};
- }
- var ids = $scope.searchkeys.selectType.id
- if(defaultFilterData.incident){
- defaultFilterData.incident.selectType = ids;
- }else{
- defaultFilterData.incident = {
- selectType:ids
- };
- }
- console.log(defaultFilterData,2222)
- $scope.onChange('all', isInit);
- }
- //获取列表数据
- $scope.refreshData = _.debounce(function (style, filterData, isInit) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- if(isInit){
- if($state.params.tab){
- $scope.searchstate = $state.params.tab;
- filterData.idx = 0;
- $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
- }
- if($state.params.date == 'today'){
- $scope.othcode = {};
- $scope.searchkeys.acceptDate = new Date();
- $scope.searchkeys.acceptDateEnd = new Date();
- if(filterData.incident){
- filterData.incident.acceptDate = moment().format('YYYY-MM-DD 00:00:00');
- filterData.incident.acceptDateEnd = moment().format('YYYY-MM-DD 23:59:59');
- }else{
- filterData.incident = {
- acceptDate: moment().format('YYYY-MM-DD 00:00:00'),
- acceptDateEnd: moment().format('YYYY-MM-DD 23:59:59'),
- }
- }
- }else{
- $scope.searchkeys.acceptDate = undefined;
- $scope.searchkeys.acceptDateEnd = undefined;
- }
- if($state.params.state){
- var obj = $scope.state.find(function(v){return $state.params.state == v.id});
- $scope.othcode = {state:obj};
- if(filterData.incident){
- filterData.incident.statusId = $state.params.state;
- }else{
- filterData.incident = {
- statusId: $state.params.state,
- }
- }
- }
- }
- }
- $scope.myData = [];
- $scope.memoryfilterData = filterData;
- $scope.gridOptions['sum'] = filterData.sum;
- // 请求参数调整
- if(!filterData.incident){
- filterData.incident = {};
- }
- if($scope.searchstate === 'all' || $scope.searchstate === 'callback'){
- if($rootScope.user.duty){
- // 当前的所属责任科室
- filterData.incident.duty = $rootScope.user.duty;
- }else if($rootScope.user.branch){
- // 当前的所属院区
- filterData.incident.branch = $rootScope.user.branch.id;
- }
- }else{
- delete filterData.incident.duty;
- delete filterData.incident.branch;
- }
- filterData.incident.queryTask = $scope.searchstate;
- filterData.incident.assignee = loginUser.id;
- if($scope.searchstate === 'todo' || $scope.searchstate === 'owns'){
- filterData.incident.candidateGroups = loginuserGroup;
- }else{
- delete filterData.incident.candidateGroups;
- }
- // 调用接口-查列表
- api_user_data.fetchDataList('incident', filterData).then(function (data) {
- if (data.list) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions['totalItems'] = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
- }
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "请稍后再试!",
- type: "error"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function () {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- // 获取数量
- $scope.count(filterData.incident, isInit);
- }, 500);
- // 调用接口-查数量
- $scope.count = function (incident = {}){
- let postData = {
- incidentList: [],
- }
- $scope.tabs.forEach(v => {
- postData.incidentList.push({...incident, ...{queryTask: v.key}});
- })
- postData.incidentList.forEach(incident => {
- // 请求参数调整
- if(!incident){
- incident = {};
- }
- if(incident.queryTask === 'all' || incident.queryTask === 'callback'){
- if($rootScope.user.duty){
- // 当前的所属责任科室
- incident.duty = $rootScope.user.duty;
- }else if($rootScope.user.branch){
- // 当前的所属院区
- incident.branch = $rootScope.user.branch.id;
- }
- }else{
- delete incident.duty;
- delete incident.branch;
- }
- incident.assignee = loginUser.id;
- if(incident.queryTask === 'todo' || incident.queryTask === 'owns'){
- incident.candidateGroups = loginuserGroup;
- }else{
- delete incident.candidateGroups;
- }
- })
- api_flow.count(postData).then(function (data) {
- if (data.state == 200) {
- let myData = data.data || {};
- $scope.tabs.forEach(v => {
- v.num = myData[v.key];
- })
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "请稍后再试!",
- type: "error"
- });
- }
- });
- }
- // 进入页面时
- $scope.getIncidentStatus();
- $scope.timer = $interval(function () {
- $scope.jry_refresh()
- }, $rootScope.refreshTime);
- $scope.$on('$destroy', function () {
- $interval.cancel($scope.timer)
- });
- }]);
- //操作按钮权限控制
- app.controller('IncidentOperCtrl', ['$rootScope', '$scope', '$state', function ($rootScope, $scope, $state) {
- var loginUser = $rootScope.user;
- $scope.user = $rootScope.user;
- $scope.chuli = false;
- $scope.qiangdan = false;
- $scope.huifang = false;
- $scope.delFlag = false;
- $scope.storageFlag = false;
- $scope.editFlag = false;//编辑
- $scope.assignFlag = false;//指派
- $scope.transferFlag = false;//转派
- $scope.shijianliebiao_duty = false;//设置责任科室
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "shijianliebiao_chuli") {
- $scope.chuli = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_qiangdan") {
- $scope.qiangdan = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_huifang") {
- $scope.huifang = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_del") {
- $scope.delFlag = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_build") {
- $scope.storageFlag = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_edit") {
- $scope.editFlag = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_assign") {
- $scope.assignFlag = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_transfer") {
- $scope.transferFlag = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_duty") {
- $scope.shijianliebiao_duty = true
- }
- }
- $scope.up = true;
- $scope.fuwutaiRenYuan = false;//服务台人员
- for (var i = 0; i < $rootScope.user.role.length; i++) {
- if ($rootScope.user.role[i].role == '事件经理') {
- $scope.up = false;
- }
- if ($rootScope.user.role[i].id == 29701) {
- $scope.fuwutaiRenYuan = true;
- }
- }
- $rootScope.callid = $scope.item.callID;
- if ($scope.item.callID) {
- $scope.item.listen = true;
- } else {
- $scope.item.listen = false;
- }
- $rootScope.user.group.forEach(function (item, v) {
- if($scope.item.currentLog){
- if (item.id == $scope.item.currentLog.groupId) {
- $scope.item.tiquPower = true;
- }
- }
- })
- //修改页面显示判断
- $scope.jry_modify = function (item) {
- var arrFlag = ['pending','handler'];
- var stateFlag = arrFlag.includes(item.state.value)
- return stateFlag && $scope.editFlag;
- }
- // 回访操作权限
- for (var obj in $rootScope.user.role) {
- if ($rootScope.user.role[obj].rolecode == 'call center') {
- if ($scope.item.state.id == 1546) {
- $scope.item.huifang = true;
- } else {}
- }
- }
- $scope.edit = function () {
- $scope.colobject.grid.appScope.selectRowFunction($scope.item);
- }
- $scope.changeCenter = function () {
- $scope.colobject.grid.appScope.changeClick($scope.item);
- }
- $scope.visit = function () {
- $scope.colobject.grid.appScope.visit($scope.item);
- }
- // 指派
- $scope.toAssign = function () {
- $scope.colobject.grid.appScope.toAssign($scope.item);
- }
- // 转派
- $scope.toTransfer = function () {
- $scope.colobject.grid.appScope.toTransfer($scope.item);
- }
- // 删除事件
- $scope.delSj = function () {
- $scope.colobject.grid.appScope.delSj($scope.item);
- }
- // 继续创建
- $scope.storageSj = function () {
- $scope.colobject.grid.appScope.storageSj($scope.item);
- }
- // 新增延期处理
- $scope.toHandlerLog = function () {
- $scope.colobject.grid.appScope.toHandlerLog($scope.item);
- }
- // 设置责任科室
- $scope.setDuty = function () {
- $scope.colobject.grid.appScope.setDuty($scope.item);
- }
- $scope.play = function () { //record
- $scope.colobject.grid.appScope.play($scope.item);
- }
- $scope.handler = function () {
- $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
- }
- //查看
- $scope.toDetail = function (data) {
- console.log(data,$rootScope.isFuwutai);
- if($rootScope.isFuwutai){
- //角色是服务台人员
- $state.go('app.incident.incidentDetail', {
- id: data.id,
- });
- }else{
- window.open(location.origin+'/#/app/incident/incidentDetail/'+data.id);
- }
- };
- }]);
- //操作按钮
- app.directive('incidentoperator', function () {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- },
- controller: 'IncidentOperCtrl',
- template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" style="text-align:left;">' +
- '<a ng-click="toDetail(item)" class="bianjifont" >查看</a>' +
- // '<a ng-click="changeCenter()" ng-show="jry_modify(item)" class="luyinfont">编辑</a>' +
- '<a ng-click="delSj()" ng-show="{{delFlag && item.state.value !== \'deleted\'}}" class="assign" >删除</a>' +
- '<a ng-click="storageSj()" ng-show="{{storageFlag && item.state.value === \'storage\'}}" class="assign" >继续创建</a><br>' +
- '<a ng-click="edit()" ng-show="{{item.state.value == \'handler\' && item.handlingPersonnelUser && item.handlingPersonnelUser.id == user.id && chuli}}" class="bianjifont">处理</a>' +
- '<a ng-click="handler()" ng-show="{{item.state.value == \'pending\' && ((item.currentLog && item.currentLog.workerId == user.id) || item.tiquPower) && qiangdan}}" class="bianjifont" >接单</a>' +
- '<a ng-click="visit()" ng-show="{{item.state.value == \'close\' && huifang}}" class="bianjifont">回访</a>' +
- '<a ng-click="toAssign()" ng-show="{{(item.state.value == \'pending\' || item.state.value == \'handler\' || item.state.value == \'reassign\') && assignFlag}}" class="assign" >指派</a>' +
- '<a ng-click="toTransfer()" ng-show="{{item.state.value == \'handler\' && item.handlingPersonnelUser && item.handlingPersonnelUser.id == user.id && !assignFlag && transferFlag}}" class="assign" >转派</a>' +
- '<a ng-click="toHandlerLog()" ng-show="{{item.state.value == \'handler\'}}" class="assign" >延期处理</a>' +
- '<a ng-click="setDuty()" ng-show="{{shijianliebiao_duty && (item.state.value == \'resolved\' || item.state.value == \'close\')}}" class="assign" >设置责任科室</a>' +
- '</div></div>'
- };
- });
|