12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402 |
- '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 = {deleted:false};
- // 是否选择已删除
- $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: 0,
- }
- }).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();
- 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};
- 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;
- });
- // 调用接口-查数量
- let numPostData = {
- tabs: $scope.tabs.map(v => v.key).toString(),
- assignee: loginUser.id,
- candidateGroups: loginuserGroup,
- }
- if($rootScope.user.duty){
- // 当前的所属责任科室
- numPostData.dutyId = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- // 当前的所属院区
- numPostData.branchId = $rootScope.user.branch.id;
- }
- api_flow.count(numPostData).then(function (data) {
- if (data.state == 200) {
- let myData = data.data[0] || {};
- $scope.tabs.forEach(v => {
- v.num = myData[v.key];
- })
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "请稍后再试!",
- type: "error"
- });
- }
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function () {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- }, 500);
- // 进入页面时
- $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>'
- };
- });
|