123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775 |
- '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', 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) {
- //保存报修主体
- $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
- // ----------------分割线 start-----------------
- // 故障地点下拉
- // $scope.addressModel = '';//文本输入内容
- $scope.address_arr = [];//故障地点所有数据
- $scope.addressFlag = false;//默认下拉框列表隐藏
- //点击文本框
- $scope.addressClickHandle = function () {
- $scope.searchkeys.houseNumber = $scope.searchkeys.houseNumber === undefined?'':$scope.searchkeys.houseNumber;
- $scope.getDepartmentList();
- angular.element('#bx_address_ul').scrollTop(0);
- }
- //修改文字,实时监听
- $scope.addressChangeHandle = _.debounce(function () {
- $scope.getDepartmentList();
- angular.element('#bx_address_ul').scrollTop(0);
- }, 500)
- //获取故障地点seimin
- $scope.getDepartmentList = function () {
- api_search_area.getAreaList({ "searchKey": $scope.searchkeys.houseNumber })
- .then(res => {
- if (res.state == 200) {
- $scope.address_arr = res.result;
- $scope.addressFlag = true;//显示
- }
- })
- .catch(err => {
- console.log(err);
- })
- }
- //下拉框列表选中
- $scope.addressItemClick = function (obj) {
- $scope.addressFlag = false;//隐藏
- $scope.searchkeys.houseNumber = obj.place ? obj.area.area + obj.place : obj.area;//文本框赋值
- }
- //点击空白处隐藏
- angular.element(document).on('click', function (e) {
- if (e.target !== angular.element('#bx_address').get(0)) {
- $scope.addressFlag = false;//隐藏
- }
- })
- // -----------------分割线 end----------------
- // 是否逾期seimin
- $scope.selectType = [
- { id: '2', name: '是' },
- { id: '0', name: '否' }
- ];
- // /是否逾期
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.myData = [];
- var loginUser = $rootScope.user;
- console.log(loginUser);
- $scope.daochu = false;
- for (var i = 0; i < loginUser.menu.length; i++) {
- 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;
- }
- }
- //新增事件seimin
- $scope.goToAddIncident = function () {
- $state.go('app.incident.editor', {});
- }
- //全部事件权限
- // $scope.allright = false;
- // $scope.allrightnot = true;
- // for (var obj in $rootScope.user.role) {
- // if ($rootScope.user.role[obj].rolecode == 'incident manager' || $rootScope.user.role[obj].rolecode == 'call center') {
- // $scope.allright = true;
- // $scope.allrightnot = false;
- // }
- // }
- // 处理人,受理人,转派人
- var acceptUser;
- var pdKey = $state.current.pdKey;
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $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.states = [
- {
- id: "all",
- name: '全部的事件'
- },
- {
- id: "todo",
- name: '待我处理的事件'
- },
- {
- id: "create",
- name: '我创建的事件'
- },
- {
- id: "done",
- name: '我处理过的事件'
- }
- ];
- // for (var obj = 0; obj < $rootScope.user.role.length; obj++) {
- // if ($rootScope.user.role[obj].rolecode == 'incident manager' || $rootScope.user.role[obj].rolecode == 'call center') {
- // $scope.states = [
- // { id: "all", name: '全部的事件' },
- // { id: "todo", name: '待我处理的事件' },
- // { id: "create", name: '我创建的事件' },
- // { id: "done", name: '我处理过的事件' }
- // ];
- // }
- // }
- $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 = "正常";
- }
- } else {
- // color = "white";
- }
- 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: '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">{{row.entity.houseNumber}}</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: 250,
- cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
- enableFiltering: false
- },
- ];
- }else if($scope.repairMain.valueconfig == 2){//报修科室
- $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: 'department.dept',
- displayName: '报修科室',
- width: '6%',
- minWidth: '90',
- enableSorting: false,
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" >{{row.entity.department.dept}}</div>' +
- '</div>'
- },
- {
- name: 'department.phone',
- displayName: '联系电话',
- width: '105',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents">{{row.entity.department.phone}}</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">{{row.entity.houseNumber}}</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: 250,
- cellTemplate: '<incidentoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">',
- enableFiltering: false
- },
- ];
- }
- $scope.value = 10;
- $scope.decrement = function () {
- $scope.value = $scope.value - 1;
- };
- $scope.record = function () {
- api_text.record($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $scope.busy = false;
- }
- })
- };
- $scope.transferTime = function (time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $scope.parameters = null;
- $scope.open = function ($event) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.opened = !$scope.opened;
- };
- $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.searchkeys = {selectType:{id:2,name:'是'}};//seimin
- // 事件分类
- var apple_selected, tree, treedata_avm, treedata_geography;
- $scope.my_tree_handler = function (branch) {
- //var _ref;
- var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
- api_cmdb.query({ 'sign': classify }).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- // console.log(myData.data.node);
- if (myData.data && myData.status == 200) {
- var ret = myData.data;
- redrawSvg(myData);
- }
- });
- };
- $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 = tree = {};
- // $scope.try_async_load = function() {
- // $scope.my_data = [];
- // $scope.select_treedata = [];
- // $scope.doing_async = true;
- // api_configure_data.fetchDataList('ciclassify', { 'idx': 0, 'sum': 100 }).then(function(result) {
- // $scope.my_tree = result['list'];
- // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
- // $scope.doing_async = false;
- // // tree.expand_all();
- // //console.log(treelist);
- // });
- // };
- $scope.select_treedata = [];
- $scope.propTypeOptions = [];
- // $scope.try_async_load();
- // $scope.onFilterCallback = function(item) {
- // console.log(item);
- // if (angular.isDefined(item.children) && item.children.length >= 1) {
- // //not valid
- // } else {
- // var tempclassify = (item.item?item.item.prefix.toLowerCase():item.prefix.toLowerCase()) + (item.item?item.item.sign:item.sign);
- // $scope.gridApi.grid.options.paginationCurrentPage = 1;
- // $scope.cifilter_classic = tempclassify;
- // var memoryfilterData = {
- // "sign": tempclassify,
- // "idx": 0,
- // "sum": $scope.gridOptions.paginationPageSize
- // }
- // angular.extend($scope.memoryfilterData, memoryfilterData);
- // $scope.fileData["sign"]=tempclassify;
- // // $scope.memoryfilterData=memoryfilterData;
- // $scope.refreshData('expand-right', $scope.fileData);
- // // 专有属性
- // api_configure_form.renderTabForm(tempclassify).then(function(data) {
- // var myData = Restangular.stripRestangular(data);
- // angular.forEach(myData, function(item, index) {
- // if (index == 0) {
- // $scope.propTypeOptions = myData[0].form.fields;
- // } else {
- // angular.forEach(item.form.fields, function(itemdata) {
- // $scope.propTypeOptions.push(itemdata)
- // })
- // }
- // })
- // // $scope.propTypeOptions = myData[2].form.fields;
- // console.log($scope.propTypeOptions)
- // });
- // }
- // }
- // 报修科室
- $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();
- var apple_selected, tree, treedata_avm, treedata_geography;
- $scope.my_tree_handler = function (branch) {
- //var _ref;
- var classify = $scope.classify = branch.prefix.toLowerCase() + branch.sign;
- api_cmdb.query({
- 'sign': classify
- }).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- // console.log(myData.data.node);
- if (myData.data && myData.status == 200) {
- var ret = myData.data;
- redrawSvg(myData);
- }
- });
- };
- //树形图
- // $scope.inspecttype = {};
- // 将事件分类搜索结果返回的数据整理成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
- }
- if (filterKeyword) {
- postData.incidentcategory = { selectType: "pinyin_qs", category: filterKeyword }
- }
- $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;
- // if (data[i].parent && data[i].parent.id != 0) {
- // object.parent = data[i].parent.id;
- // }
- 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;
- console.log(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.select_treedata = [];
- $scope.propTypeOptions = [];
- $scope.deselectItem = function (item) {
- console.log(item)
- console.log($scope)
- }
- // 事件分类
- $scope.onFilterCallback = function (item) {
- // $scope.searchkeys.category={};
- console.log(item);
- if (item.item) {
- $scope.searchkeys.category = item = undefined;
- } else {
- $scope.searchkeys.category = item;
- }
- // if (angular.isDefined(item.children) && item.children.length >= 1) {
- // //not valid
- // } else {
- // var tempclassify = item.prefix.toLowerCase() + item.sign;
- // $scope.gridApi.grid.options.paginationCurrentPage = 1;
- // $scope.cifilter_classic = tempclassify;
- // var memoryfilterData = {
- // "sign": tempclassify,
- // "idx": 0,
- // "sum": $scope.gridOptions.paginationPageSize
- // }
- // angular.extend($scope.memoryfilterData, memoryfilterData)
- // // $scope.memoryfilterData=memoryfilterData;
- // $scope.refreshData('expand-right', $scope.memoryfilterData);
- // // 专有属性
- // var postData={
- // idx:0,
- // sum:1000
- // }
- // api_bpm_data.fetchDataList('incidentcategory',postData).then(function(data){
- // console.log(data)
- // var myData = Restangular.stripRestangular(data);
- // $scope.propTypeOptions = myData[2].form.fields;
- // // console.log($scope.propTypeOptions)
- // });
- // }
- }
- //状态
- $scope.state = [];
- // api_bpm_data.fetchDataList('incidentstatus', { "idx": 0, "sum": 100 }).then(function(response) {
- api_wechatfile.getDictionary({
- "type": "list",
- "key": "incident_status"
- }).then(function (response) {
- if (response) {
- if (response.status = 200) {
- $scope.state = response;
- if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).incident) {
- angular.forEach($scope.state, function (item) {
- if (item.id == JSON.parse(sessionStorage.getItem("searchincident")).incident.statusId) {
- $scope.othcode = {
- "state": item
- };
- }
- })
- }
- }
- }
- })
- if (sessionStorage.searchincident && JSON.parse(sessionStorage.getItem("searchincident")).incident) {
- // angular.forEach($scope.state, function(item) {
- // if (item.code == JSON.parse(sessionStorage.getItem("searchincident")).incident.statusId) {
- // $scope.othcode = item.id;
- // }
- // })
- // $scope.othcode = JSON.parse(sessionStorage.getItem("searchincident")).incident.statusId;
- if (JSON.parse(sessionStorage.getItem("searchincident")).incident) {
- $scope.searchkeys = JSON.parse(sessionStorage.getItem("searchincident")).incident;
- }
- if ($scope.searchkeys.acceptDate) {
- $scope.searchkeys.acceptDate = new Date($scope.searchkeys.acceptDate);
- }
- if ($scope.searchkeys.acceptDateEnd) {
- $scope.searchkeys.acceptDateEnd = new Date($scope.searchkeys.acceptDateEnd);
- }
- // $scope.gridOptions.paginationCurrentPage = 1 + JSON.parse(sessionStorage.getItem("searchincident")).idx;
- }
- $scope.clear = function () {
- $scope.propTypeOptions = [];
- $scope.searchkeys = {};
- $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
- $scope.othcode = {};
- $scope.try_async_load();
- var fildata = {
- "assignee": loginUser.id,
- "candidateGroups": loginuserGroup,
- "searchType": JSON.parse(sessionStorage.getItem("searchincident")).searchType,
- "idx": JSON.parse(sessionStorage.getItem("searchincident")).idx,
- "sum": JSON.parse(sessionStorage.getItem("searchincident")).sum
- }
- sessionStorage.removeItem("searchincident");
- fildata.assignee = loginUser.id;
- $scope.memoryfilterData = fildata;
- $scope.refreshData('expand-right', fildata);
- $interval.cancel($scope.timer);
- $scope.timer = $interval(function () {
- $scope.jry_refresh()
- }, $rootScope.refreshTime);
- }
- // 刷新
- $scope.jry_refresh = function () {
- var fildata = {};
- if (sessionStorage.searchincident) {
- fildata = JSON.parse(sessionStorage.getItem("searchincident"));
- } else {
- fildata = defaultFilterData;
- }
- if (fildata.incident && fildata.incident.category) {
- delete fildata.incident.category
- }
- fildata.idx = $scope.jry_idx;
- fildata.sum = $scope.jry_sum;
- $scope.refreshData2('expand-right', fildata);
- console.log($scope.cifilter_classic);
- }
- // 搜索
- $scope.chiceIncident = function (item, stateid) {
- if (stateid && stateid.id) {
- item.statusId = stateid.id;
- } else {
- item.statusId = undefined;
- }
- console.log(item)
-
- var fildata = {};
- if (sessionStorage.searchincident) {
- fildata = JSON.parse(sessionStorage.getItem("searchincident"));
- $scope.gridOptions.paginationCurrentPage = 1;
- fildata.idx = 0;
- } else {
- fildata = defaultFilterData;
- }
- // $scope.memoryfilterData = fildata;
- if (!fildata.incident) {
- fildata['incident'] = {};
- }
- // $scope.gridOptions.paginationCurrentPage = 1;
- if (item.acceptDate) {
- item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD HH:mm:ss');
- }
- if (item.acceptDateEnd) {
- // item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD HH:mm:ss');
- item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD 23:59:59')
- }
- // if (parameters) {
- // angular.extend(fildata, { 'idx': 0, 'sum': $scope.gridOptions.paginationPageSize })
- // angular.extend(fildata.incident, { 'acceptDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'), 'acceptDateEnd': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59') })
- // }
-
- var transitiondata = angular.copy(item);
- angular.extend(fildata.incident, transitiondata)
- sessionStorage['searchincident'] = JSON.stringify(fildata);
- $scope.memoryfilterData = fildata;
- fildata.assignee = loginUser.id;
- // seimin
- console.log(fildata,78777);
- if(fildata.searchType === '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);
- $interval.cancel($scope.timer);
- $scope.timer = $interval(function () {
- $scope.jry_refresh()
- }, $rootScope.refreshTime);
- }
- //区域地点过滤
- $scope.key = {};
- 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('requester', {
- idx: 0,
- sum: 100
- }).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) {
- // console.log(data);
- if (it == 1) {
- $scope.acceptUser = data.list;
- acceptUser = $scope.acceptUser;
- } else if (it == 2) {
- $scope.handlingPersonnelUser = data.list;
- // } else if (it == 3) {
- // $scope.acceptUser = data.list;
- // $scope.handlingPersonnelUser = data.list;
- }
- });
- }
- //受理人过滤
- $scope.onChangeacceptUser = function (key) {
- console.log(key)
- var filuser = {
- "idx": 0,
- "sum": 10,
- "user": {
- "name": key,
- 'selectType': "pinyin_qs"
- }
- }
- getUser(filuser, 1);
- }
- //处理人过滤
- $scope.onChangehandling = function (key) {
- var filuser = {
- "idx": 0,
- "sum": 10,
- "user": {
- "name": key,
- 'selectType': "pinyin_qs"
- }
- }
- 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) {
- // if (data.area && data.place) {
- // if (data.houseNumber) {
- var str = ' ';
- 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;
- // } else {
- // return data.area.area + ' ' + data.place.place;
- // }
- // } else if (data.area && !data.place) {
- // if (data.houseNumber) {
- // return data.area.area + ' ' + data.houseNumber;
- // } else {
- // return data.area.area;
- // }
- // } else if (!data.area && data.place) {
- // if (data.houseNumber) {
- // return data.place.place + ' ' + data.houseNumber;
- // } else {
- // return data.place.place;
- // }
- // }
- }
- //录音
- $scope.play = function (data) {
- // console.log($scope.item.callID)
- var modalInstance = $modal.open({
- backdrop: "static",
- templateUrl: 'assets/views/incident/tpl/audio.html',
- controller: function ($rootScope, $scope, $modalInstance, $sce, $http, api_playservice) {
- $rootScope.setbusy();
- $scope.datasurl = "";
- $http({
- url: callIp + "/recording/recording?callID=" + data.callID,
- method: 'GET',
- headers: {},
- }).success(function (data, status, headers, config) {
- $scope.data = {
- "name": "视频",
- "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
- };
- $scope.datasurl = data.rrpath;
- }).error(function (data, status, headers, config) { });
- $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) {
- // $rootScope.setidle();
- }, function (reason) {
- $rootScope.setidle();
- });
- };
- $scope.jry_paging = "";
- //列表排序
- // sessionStorage.idx = 0;
- $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) {
- // index = 0;
- } 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"
- });
- }
- }
- // angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
- }
- fildata.assignee = loginUser.id;
- $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_paging = newPage - 1;
- $scope.jry_idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.jry_sum = pageSize;
- if (JSON.parse(sessionStorage.getItem("searchincident")).idx != filtersData.idx || JSON.parse(sessionStorage.getItem("searchincident")).sum != filtersData.sum) {
- filtersData.assignee = loginUser.id;
- $scope.refreshData('expand-right', filtersData);
- }
- // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
- });
- // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
- // data.grid.appScope.selected.items = data.entity
- // });
- $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 = {
- "assignee": loginUser.id,
- "candidateGroups": loginuserGroup,
- idx: 0,
- sum: mun
- };
- } else {
- var filtersData = {
- "assignee": loginUser.id,
- 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;
- filtersData.assignee = loginUser.id;
- $scope.memoryfilterData = filtersData;
- $scope.refreshData('expand-right', filtersData);
- });
- };
- //当前人是否分组
- if ($rootScope.user.group) {
- if ($rootScope.user.group.length == 0) {
- SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
- } else {
- $scope.memoryfilterData = defaultFilterData = {
- "assignee": loginUser.id,
- "candidateGroups": loginuserGroup,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- }
- } else {
- $scope.memoryfilterData = defaultFilterData = {
- "assignee": loginUser.id,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- }
- //打印
- $scope.open = function (data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/print.html',
- controller: function ($scope, $modalInstance) {
- $scope.printdata = data;
- if (!data.emergency) {
- data['emergency'] = {};
- }
- if (!data.influence) {
- data['influence'] = {};
- }
- if (!data.place) {
- data['place'] = {};
- }
- if (!data.influence) {
- data['influence'] = {};
- }
- if (!data.emergency) {
- data['emergency'] = {};
- }
- if (!data.influence) {
- data['influence'] = {};
- }
- var height = $(".groundborder").height()
- // console.log(height)
- $scope.printrequest = [{
- name: "事件单号",
- value: data.incidentsign
- },
- {
- name: "事件主题",
- value: data.title
- },
- {
- name: "事件分类",
- value: data.category.category
- },
- {
- name: "紧急度",
- value: data.emergency.name
- },
- {
- name: "影响度",
- value: data.influence.name
- },
- {
- name: "优先级",
- value: data.priority.name
- }
- ];
- $scope.printrequest['requester'] = [{
- nameone: "用户姓名",
- valueone: data.requester.name,
- nametwo: "联系电话",
- valuetwo: data.requester.mphone
- },
- {
- nameone: "故障地点",
- valueone: data.place.place,
- nametwo: "申报时间",
- valuetwo: data.acceptDate
- }
- ];
- // $scope.printrequest['requester']=[{name:"用户姓名",value:data.requester.name},
- // {name:"联系电话",value:data.requester.mphone},
- // {name:"故障地点",value:data.place.place},
- // {name:"申报时间",value:data.responseTime}];
- $scope.printrequest['incident'] = [{
- nameone: "故障工单",
- valueone: data.incidentsign,
- nametwo: "故障分类",
- valuetwo: data.category.category
- }];
- $scope.printrequest['handler'] = [{
- name: "故障描述",
- value: data.description
- },
- {
- name: "处理人",
- value: data.handlingPersonnelUser ? data.handlingPersonnelUser.name : ''
- },
- // { name: "处理人", value: data.requester ? data.requester.name : '' }
- ];
- // {name:"处理结果",value:data.handleResult}];
- // {name:"用户评价",value:''},
- // {name:"满意度",value:''},
- // {name:"用户签字",value:''}];
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg'
- });
- }
- //新建事件
- $scope.newincident = function (data) {
- $state.go('app.incident.editor', {});
- };
- //编辑
- $scope.selectRowFunction = function (data) {
- $state.go('app.incident.editor', {
- taskId: data.taskId,
- processInstanceId: data.processInstanceId,
- dataId: data.id,
- // type:1
- });
- };
- // //双击查看详情
- // $scope.onDblClick = function (data) {
- // console.log(data);
- // // console.log('data='+JSON.stringify(data));
- // //$state.go('app.detail',{taskId:data.taskId,processInstanceId: data.processInstanceId});
- // $state.go('app.incident.detail', {
- // formKey: 'incident_back',
- // pdKey: 'incident',
- // dataId: data.entity.id,
- // taskId: data.entity.taskId,
- // processInstanceId: data.entity.processInstanceId
- // });
- // };
- //修改
- $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 (data) {
- $state.go('app.incident.detail', {
- formKey: 'incident_visit',
- pdKey: 'incident',
- dataId: data.id,
- taskId: data.taskId,
- processInstanceId: data.processInstanceId
- });
- };
- //查看
- $scope.followFunction = function (data) {
- //console.log('data='+JSON.stringify(data));
- console.log(data);
- $state.go('app.detail', {
- formKey: 'statusform',
- pdKey: 'incident',
- dataId: data.id,
- processInstanceId: data.processInstanceId
- });
- };
- // 升级
- $scope.upgrade = function (data) {
- console.log(data);
- console.log('升级');
- // 弹窗下拉菜单单选
- } // 转派
- $scope.rotate = function (data) {
- console.log(data);
- console.log('转派');
- // 弹窗下拉菜单单选
- } // 协同
- $scope.cooperate = function (data) {
- console.log(data);
- console.log('协同');
- // 弹窗下拉菜单多选
- }
- // 升级问题
- $scope.problem = function (data) {
- // console.log(data);
- delete data.item;
- delete data.chaozuoPower;
- delete data.coordination;
- delete data.listen;
- // console.log(data);
- $state.go('app.problem.incident', {
- 'model': JSON.stringify(data)
- });
- }
- //变更升级
- $scope.configuration = function (data) {
- $state.go('app.change.incident', {
- 'model': JSON.stringify(data)
- });
- };
- //协同人
- $scope.coordination = function (data) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
- controller: function ($scope, $modalInstance, i18nService, $timeout, api_bpm_domain, api_user_data) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = true;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = true;
- $scope.gridOptions.fastWatch = true;
- $scope.gridOptions.useExternalFiltering = true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = false;
- $scope.gridOptions.rowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function (row) {
- return row.id;
- };
- $scope.gridOptions.columnDefs = [
- // { name:'id', width:80, enableFiltering:false},
- {
- name: 'account',
- displayName: '账号',
- width: 140
- },
- {
- name: 'name',
- displayName: '名称',
- width: 100
- },
- {
- name: 'gender',
- displayName: '性别',
- width: 140,
- enableFiltering: false
- },
- {
- name: 'phone',
- displayName: '电话',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'email',
- displayName: '邮件',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'dept.dept',
- displayName: '科室',
- width: 100,
- enableFiltering: false
- },
- {
- name: 'group[0].groupName',
- displayName: '职位',
- width: 100,
- enableFiltering: false
- }
- ];
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.loadData(filtersData);
- // $scope.loadData({"idx":newPage-1,"sum":pageSize});
- });
- gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
- scope.grid.appScope.selected.items[0] = scope.entity;
- // $scope.selected.items[0] = scope.entity;
- });
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filtersData = {
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": options.model.currentRole
- },
- "selectType": "1"
- }
- };
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- //console.log("filtersData="+JSON.stringify(filtersData))
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['user'] = {};
- }
- filtersData['user'][item.field] = item.filters[0].term;
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.loadData(filtersData);
- });
- };
- $scope.selected = {
- items: []
- }
- var filterData = {
- "idx": 0,
- "sum": 10,
- "user": {
- "roledata": {
- "rolecode": 'first-line support'
- },
- "selectType": "1"
- }
- }
- $scope.loadData = function (filterData) {
- // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
- api_user_data.fetchDataList('user', filterData).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- $scope.myData = myData.list;
- });
- };
- $scope.loadData({
- idx: 0,
- sum: 10,
- "user": {
- "roledata": {
- "rolecode": 'first-line support'
- },
- "selectType": "1"
- }
- });
- $scope.ok = function () {
- $modalInstance.close($scope.selected.items);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'lg'
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- var filterData = {
- "assginee": selectedItem[0].id
- }
- api_bpm_domain.delegateTask(data.taskId, filterData).then(function (data) {
- if (data && data.status == 200) {
- SweetAlert.swal("添加成功!", "添加协同人成功", "success");
- $scope.memoryfilterData.assignee = loginUser.id;
- $scope.refreshData('expand-right', $scope.memoryfilterData);
- } else {
- SweetAlert.swal("添加失败!", "请稍候重试", "error");
- }
- // var myData = Restangular.stripRestangular(data);
- // $scope.gridOptions.totalItems = myData.totalNum;
- // $scope.myData = myData.list;
- });
- }
- });
- }
- // $scope.onDblClick = function(row){
- // console.log(row.entity);
- // if($rootScope.user.id==row.entity.handlerUser.id){$state.go('app.incident.editor',{taskId:row.entity.taskId,processInstanceId: row.entity.processInstanceId});}
- // else{$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: row.entity.id});}
- // };
- /*
- appScopeProvider: {
- onDblClick : function(row) {
- var url = '//google.com';
- $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
- }
- },
- rowTemplate: "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" ui-grid-cell ></div>"
- */
- //删除
- $scope.eventDeleted = function (event) {
- SweetAlert.swal({
- title: "确认删除?",
- text: "删除的数据不可恢复,请确认继续操作!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "继续删除",
- cancelButtonText: "取消操作",
- closeOnConfirm: false,
- closeOnCancel: false
- }, function (isConfirm) {
- if (isConfirm) {
- api_bpm_schedule.remove([event.id]).then(function (response) {
- if (response.status == 200) {
- $scope.events.splice(event.id, 1); //有修改的一行
- SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
- } else {
- SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
- }
- });
- } else {
- SweetAlert.swal("操作取消", "数据安全", "error");
- }
- });
- };
- //导出
- $scope.export = function () {
- // api_bpm_data.downDataModel("incident", 3, $scope.memoryfilterData).then(function(data) {
- // console.log(data)
- // var file = new Blob([data], {
- // // type: 'application/octet-stream'
- // 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();
- // })
- // $scope.ldloading[style.replace('-', '_')] = true;
- 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: {
- // 'Content-type': 'application/xls',
- 'Accept': '*/*'
- },
- responseType: 'arraybuffer'
- }).success(function (data, status, headers, config) {
- // $scope.ldloading.zoom_in = false;
- 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, APIService, modelData, currentUserId, Alert) {
- var receiveTask = function (receive_code, modelData) {
- var data = {
- 'receive_code': receive_code
- };
- if (modelData) {
- return {
- taskId: modelData.taskId,
- data: data
- };
- } else {
- return 'error';
- }
- };
- $scope.title = "提示";
- $scope.connect = "确认抢单?";
- $scope.ok = function () {
- //接收任务//请求重新指派
- var data = receiveTask($scope.receive_code, modelData);
- APIService.claimAndCompletedTask(data.taskId, {
- userId: currentUserId,
- receive_code: "handler"
- }).then(function (response) {
- if (response.status == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else if (response.status == 500) {
- Alert.swal({
- title: "操作失败",
- text: "该事件已被提取,请刷新页面!",
- type: "error"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- APIService: function () {
- return api_bpm_domain;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- defaultFilterData.assignee = loginUser.id;
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 升级弹窗
- $scope.upgrade = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/upgrade.tpl.html',
- controller: function ($scope, $modalInstance, api_bpm, modelData, currentUserId, Alert, api_user_data) {
- console.log(model);
- $scope.roleList = {
- 'idx': 0,
- 'sum': 100,
- 'user': {
- 'roledata': {
- 'rolecode': ''
- },
- 'groupdata': {
- 'id': ''
- },
- 'selectType': 1
- }
- }
- for (var i = 0; i < loginUser.role.length; i++) {
- // console.log(loginUser.role[i])
- if (loginUser.role[i].role == '一线支持人员') {
- $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
- $scope.upRole = '二线支持人员';
- }
- if (loginUser.role[i].role == '二线支持人员') {
- $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
- $scope.upRole = '事件经理';
- }
- }
- var userId = loginUser.id;
- var taskId = model.taskId;
- var postData = {};
- var formKey = model.formKey;
- var processInstanceId = model.processInstanceId;
- $scope.choosUser = {};
- api_configure_form.renderForm(formKey, userId, processInstanceId).then(function (data) {
- postData = data.model;
- })
- $scope.choosUser = {};
- api_user_data.fetchDataList('group', {
- "idx": 0,
- "sum": 100
- }).then(function (data) {
- $scope.group = data.list;
- })
- $scope.onChangeGroup = function (item) {
- $scope.user = [];
- console.log(item);
- console.log($scope.choosUser.group)
- $scope.roleList.user.groupdata.id = $scope.choosUser.group.id
- console.log($scope.roleList)
- if ($scope.choosUser.group) {
- api_user_data.fetchDataList('user', $scope.roleList).then(function (data) {
- console.log(data);
- if (data.list.length == 0) {
- Alert.swal({
- title: "暂无处理人数据",
- text: "该工作组暂无升级对象!",
- type: "error"
- });
- return;
- } else {
- $scope.user = data.list;
- }
- })
- }
- }
- $scope.ok = function () {
- if ($scope.choosUser.handlerUser) {
- postData.handler_code = 'function';
- postData.incident.handlerUser = $scope.choosUser.handlerUser;
- postData.incident.assignee = postData.assignee = $scope.choosUser.handlerUser.id;
- console.log(postData);
- } else {
- Alert.swal({
- title: "操作失败",
- text: "请选择升级对象信息!",
- type: "error"
- });
- return;
- }
- api_bpm.upgrade(postData, taskId, userId, 'completeTask').then(function (response) {
- console.log(response)
- if (response.status == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else if (response.status == 500) {
- Alert.swal({
- title: "操作失败",
- text: "该事件已被提取,请刷新页面!",
- type: "error"
- });
- $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') {
- defaultFilterData.assignee = loginUser.id;
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 转派弹窗
- $scope.rotate = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/rotate.tpl.html',
- controller: function ($scope, $modalInstance, api_bpm, modelData, currentUserId, Alert, api_user_data) {
- console.log(model);
- $scope.roleList = {
- 'idx': 0,
- 'sum': 100,
- 'user': {
- 'roledata': {
- 'rolecode': ''
- },
- 'groupdata': {
- 'id': ''
- },
- 'selectType': 1
- }
- }
- for (var i = 0; i < loginUser.role.length; i++) {
- // console.log(loginUser.role[i])
- if (loginUser.role[i].role == '一线支持人员') {
- $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
- $scope.upRole = loginUser.role[i].role;
- }
- if (loginUser.role[i].role == '二线支持人员') {
- $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
- $scope.upRole = loginUser.role[i].role;
- }
- if (loginUser.role[i].role == '事件经理') {
- $scope.roleList.user.roledata.rolecode = loginUser.role[i].rolecode;
- $scope.upRole = loginUser.role[i].role;
- }
- }
- var userId = loginUser.id;
- var taskId = model.taskId;
- var postData = {};
- var formKey = model.formKey;
- var processInstanceId = model.processInstanceId;
- $scope.choosUser = {};
- api_configure_form.renderForm(formKey, userId, processInstanceId).then(function (data) {
- postData = data.model;
- })
- api_user_data.fetchDataList('group', {
- "idx": 0,
- "sum": 100
- }).then(function (data) {
- $scope.group = data.list;
- })
- $scope.onChangeGroup = function (item) {
- $scope.roleList.user.groupdata.id = $scope.choosUser.group.id
- console.log($scope.choosUser);
- if ($scope.choosUser.group) {
- api_user_data.fetchDataList('user', $scope.roleList).then(function (data) {
- console.log(data);
- if (data.list.length == 0) {
- Alert.swal({
- title: "暂无处理人数据",
- text: "该工作组暂无转派对象!",
- type: "error"
- });
- return;
- } else {
- $scope.user = data.list;
- }
- })
- }
- }
- $scope.ok = function () {
- if ($scope.choosUser.handlerUser) {
- postData.handler_code = 'forward';
- postData.incident.handlerUser = $scope.choosUser.handlerUser;
- postData.incident.assignee = postData.assignee = $scope.choosUser.handlerUser.id;
- console.log(postData);
- } else {
- Alert.swal({
- title: "操作失败",
- text: "请选择转派对象信息!",
- type: "error"
- });
- return;
- }
- api_bpm.upgrade(postData, taskId, userId, 'completeTask').then(function (response) {
- console.log(response)
- if (response.status == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else if (response.status == 500) {
- Alert.swal({
- title: "操作失败",
- text: "该事件已被提取,请刷新页面!",
- type: "error"
- });
- $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') {
- defaultFilterData.assignee = loginUser.id;
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- // 协同弹窗
- $scope.cooperate = function (model) {
- console.log(model)
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/incident/tpl/cooperate.tpl.html',
- controller: function ($scope, $modalInstance, APIService, modelData, currentUserId, Alert) {
- var receiveTask = function (receive_code, modelData) {
- var data = {
- 'receive_code': receive_code
- };
- if (modelData) {
- return {
- taskId: modelData.taskId,
- data: data
- };
- } else {
- return 'error';
- }
- };
- $scope.title = "提示";
- // $scope.connect = "升级单选组件";
- $scope.ok = function () {
- //接收任务//请求重新指派
- var data = receiveTask($scope.receive_code, modelData);
- APIService.claimAndCompletedTask(data.taskId, {
- userId: currentUserId,
- receive_code: "handler"
- }).then(function (response) {
- if (response.status == 200) {
- Alert.swal({
- title: "操作成功!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $modalInstance.close('success');
- } else if (response.status == 500) {
- Alert.swal({
- title: "操作失败",
- text: "该事件已被提取,请刷新页面!",
- type: "error"
- });
- $modalInstance.close('success');
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- APIService: function () {
- return api_bpm_domain;
- },
- modelData: function () {
- return model;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- }
- }
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem == 'success') {
- defaultFilterData.assignee = loginUser.id;
- $scope.refreshData('expand-right', defaultFilterData);
- }
- });
- }
- if ($stateParams.model) {
- if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
- $scope.searchType = JSON.parse($stateParams.model).searchType;
- } else {
- $scope.searchType = "todo";
- }
- } else {
- $scope.searchType = "todo";
- }
- // if (JSON.parse($stateParams.model).searchType) {
- // if ($rootScope.user.group) {
- // var defaultFilterData = {
- // "assignee": $rootScope.user.id,
- // "candidateGroups": loginuserGroup,
- // "searchType": JSON.parse($stateParams.model).searchType,
- // "idx": 0,
- // "sum": mun
- // };
- // } else {
- // var defaultFilterData = {
- // "assignee": $rootScope.user.id,
- // "searchType": JSON.parse($stateParams.model).searchType,
- // "idx": 0,
- // "sum": mun
- // };
- // }
- // } else {
- if ($rootScope.user.group) {
- var defaultFilterData = {
- "assignee": loginUser.id,
- "candidateGroups": loginuserGroup,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- } else {
- var defaultFilterData = {
- "assignee": $rootScope.user.id,
- "searchType": "todo",
- "idx": 0,
- "sum": mun
- };
- }
- // }
- // var defaultFilterData = {
- // "assignee":$rootScope.user.id,
- // "candidateGroups":$rootScope.user.group[0].id,
- // "idx":0,
- // "sum":mun
- // };
- if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
- defaultFilterData['searchType'] = $rootScope.search.incident;
- $scope.searchType = $rootScope.search.incident;
- }
- // if ($rootScope['cmdbs'] != 'incident') { $rootScope.idx = 1 }
- // if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
- // $rootScope['cmdbs'] = 'incident';
- // defaultFilterData.idx = $rootScope.idx - 1;
- // } else { $rootScope.cmdbs = ""; }
- $scope.ldloading = {};
- // $scope.Change= function(upTypes){
- // if(angular.isDefined(upTypes)&&upTypes=='upincident'){
- // $state.go('app.problem.incident',{});
- // }
- // else if(angular.isDefined(upTypes)&&upTypes=='upchange'){
- // $state.go('app.change.incident',{});
- // }
- // }
- //事件类型筛选
- $scope.searchstate = 'todo';
- $scope.onChange = function (searchType) {
- // console.log(defaultFilterData,'fanbu')
- if(defaultFilterData.incident){
- var lsObject = defaultFilterData.incident;
- }
- $scope.searchstate = searchType;
- defaultFilterData = $scope.memoryfilterData;
- defaultFilterData.incident = lsObject;
- defaultFilterData['searchType'] = searchType;
- defaultFilterData.assignee = loginUser.id;
- // -----------seimin-------------
- if(searchType!=='all'){
- $scope.searchkeys = {selectType:{}};//seimin
- }
- if(searchType!== 'all'&&defaultFilterData.incident&&defaultFilterData.incident.selectType){
- delete defaultFilterData.incident.selectType;
- }
- if(searchType== 'all'){
- if(!defaultFilterData.incident||!defaultFilterData.incident.selectType){
- $scope.searchkeys = {selectType:{id:'0',name:'否'}};//seimin
- }
- }
- if(Object.prototype.toString.call(defaultFilterData.incident) == "[object Object]"&&Object.keys(defaultFilterData.incident).length == 0){
- delete defaultFilterData.incident;
- }
- // -----------seimin-------------
-
- $scope.refreshData('expand-right', defaultFilterData);
- $interval.cancel($scope.timer);
- $scope.timer = $interval(function () {
- $scope.jry_refresh()
- }, $rootScope.refreshTime);
- }
- // 是否逾期下拉框选择seimin
- $scope.selectTypeChange = function(){
- console.log($scope.searchkeys.selectType,66666);
- if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
- $scope.searchkeys.selectType = {id:'2',name:'是'};
- // window.sessionStorage.removeItem('isGoyuqi');//seimin
- }
- var ids = $scope.searchkeys.selectType.id
- if(defaultFilterData.incident){
- defaultFilterData.incident.selectType = ids;//seimin
- }else{
- defaultFilterData.incident = {
- selectType:ids
- };
- }
- defaultFilterData.searchType = 'all';
- console.log(defaultFilterData,2222)
- $scope.onChange('all');
- }
- //获取列表数据
- $scope.refreshData = function (style, filterData) {
- console.log(filterData,9090)
- if (filterData && filterData.incident && filterData.incident.area) {
- filterData.incident.place = {
- id: filterData.incident.place ? filterData.incident.place.id : '',
- area: filterData.incident.area
- }
- delete filterData.incident.area
- }
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- if (sessionStorage.searchincident) {
- filterData = JSON.parse(sessionStorage.getItem("searchincident"));
- if ($scope.searchType) {
- filterData.searchType = $scope.searchType;
- }
- $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
- $scope.searchstate = filterData.searchType;
- if (filterData.incident && filterData.incident.category) {
- delete filterData.incident.category
- }
- } else {
- filterData = defaultFilterData;
- if ($scope.searchType) {
- filterData.searchType = $scope.searchType;
- if (filterData.searchType == 'overDate') {
- $scope.searchstate = 'overDate';
- }
- }
- }
- }
- // if (angular.isDefined($scope.searchTypes)) {
- // $rootScope['search'] = {};
- // filterData['searchType'] = $scope.searchTypes;
- // $rootScope['search']['incident'] = $scope.searchTypes;
- // }
- // if (sessionStorage.idx) {
- // filterData.idx = Number(sessionStorage.idx);
- // $scope.gridOptions.idx = Number(sessionStorage.idx) + 1;
- // }
- console.log(filterData,11111);
- if(window.sessionStorage.getItem('isGoyuqi') == 'yes'){
- $scope.searchkeys.selectType = {id:'2',name:'是'};
- if(filterData.incident&&filterData.incident.selectType){
- filterData.incident.selectType = '2';
- }else{
- filterData.incident = {
- selectType : '2'
- }
- }
- window.sessionStorage.removeItem('isGoyuqi');//seimin
- }
- $scope.myData = [];
- sessionStorage['searchincident'] = angular.copy(JSON.stringify(filterData));
- // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
- //var start = new Date();
- //var sec = $interval(function () {
- //$scope.callsPending++;
- $scope.memoryfilterData = filterData;
- $scope.gridOptions['sum'] = filterData.sum;
-
- api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
- if (data.data) {
- // if(filterData.searchType == 'all'){
- // //跳到全部seimin
- // $scope.searchstate = 'all';
- // }
- var myData = Restangular.stripRestangular(data);
- var list = [];
- $scope.gridOptions['totalItems'] = myData.resultCount;
- $scope.myData = myData.data;
- 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.refreshData2 = function (style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- if (angular.isUndefined(filterData)) {
- if (sessionStorage.searchincident) {
- filterData = JSON.parse(sessionStorage.getItem("searchincident"));
- if ($scope.searchType) {
- filterData.searchType = $scope.searchType;
- }
- $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
- $scope.searchstate = filterData.searchType;
- if (filterData.incident && filterData.incident.category) {
- delete filterData.incident.category
- }
- } else {
- filterData = defaultFilterData;
- if ($scope.searchType) {
- filterData.searchType = $scope.searchType;
- if (filterData.searchType == 'overDate') {
- $scope.searchstate = 'overDate';
- }
- }
- }
- }
- // if (angular.isDefined($scope.searchTypes)) {
- // $rootScope['search'] = {};
- // filterData['searchType'] = $scope.searchTypes;
- // $rootScope['search']['incident'] = $scope.searchTypes;
- // }
- // if (sessionStorage.idx) {
- // filterData.idx = Number(sessionStorage.idx);
- // $scope.gridOptions.idx = Number(sessionStorage.idx) + 1;
- // }
- // $scope.myData = [];
- sessionStorage['searchincident'] = angular.copy(JSON.stringify(filterData));
- // $scope.gridOptions.paginationCurrentPage = 1 + filterData.idx;
- //var start = new Date();
- //var sec = $interval(function () {
- //$scope.callsPending++;
- $scope.memoryfilterData = filterData;
- $scope.gridOptions['sum'] = filterData.sum;
- api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
- if (data.data) {
- var myData = Restangular.stripRestangular(data);
- var list = [];
- $scope.gridOptions['totalItems'] = myData.resultCount;
- $scope.myData = myData.data;
- 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;
- });
- };
- // 进入页面时111
- if(window.sessionStorage.getItem('searchincident')){
- var varLin = JSON.parse(window.sessionStorage.getItem('searchincident'));
- if(varLin.incident&&varLin.incident.selectType){
- if(varLin.incident.selectType == '2'){
- console.log(defaultFilterData)
- $scope.searchkeys.selectType = {id:'2',name:'是'};
- }else if(varLin.incident.selectType == '0'){
- console.log(defaultFilterData)
- $scope.searchkeys.selectType = {id:'0',name:'否'};
- }
- }
- }
- if(window.sessionStorage.getItem('isGoyuqi') === 'yes'){
- $scope.selectTypeChange();
- }else{
- $scope.refreshData('expand-right');
- }
-
- $scope.timer = $interval(function () {
- $scope.jry_refresh()
- }, $rootScope.refreshTime);
- $scope.$on('$destroy', function () {
- $interval.cancel($scope.timer)
- });
- }]);
- //操作按钮权限控制
- app.controller('IncidentOperCtrl', ['$rootScope', '$http', '$scope', '$modal', '$state', 'api_bpm_data', function ($rootScope, $http, $scope, $modal, $state, api_bpm_data) {
- // console.log('$rootScope.user3='+JSON.stringify($scope.item));
- // console.log($scope.item)
- var loginUser = $rootScope.user;
- $scope.chuli = false;
- $scope.qiangdan = false;
- $scope.dayin = false;
- $scope.huifang = 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_dayin") {
- $scope.dayin = true
- }
- if (loginUser.menu[i].link == "shijianliebiao_huifang") {
- $scope.huifang = true
- }
- }
- $scope.up = true;
- $scope.fuwutaiRenYuan = false;//服务台人员
- for (var i = 0; i < $rootScope.user.role.length; i++) {
- // console.log($rootScope.user.role[i])
- if ($rootScope.user.role[i].role == '事件经理') {
- $scope.up = false;
- }
- if ($rootScope.user.role[i].id == 29701) {
- $scope.fuwutaiRenYuan = true;
- }
- }
- if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
- // 当前登陆人和当前处理人相同,并且状态非已关闭
- if ($rootScope.user.id == $scope.item.handlerUser.id && $scope.item.state.id != 1546) {
- $scope.item.chaozuoPower = true;
- // if ($scope.item.state.id == 1544) {
- // $scope.item.coordination = true;
- // }
- }
- }
- $rootScope.callid = $scope.item.callID;
- if ($scope.item.callID) {
- $scope.item.listen = true;
- } else {
- $scope.item.listen = false;
- }
- // 抢单操作权限
- // if ($scope.item.state.id != 1546 && $scope.item.handlerUser == null) {
- // angular.forEach($rootScope.user.group, function (item) {
- // if (item.id == $scope.item.candidateGroups) {
- // $scope.item.tiquPower = true;
- // }
- // })
- $rootScope.user.group.forEach(function (item, v) {
- if (item.id == $scope.item.candidateGroups) {
- $scope.item.tiquPower = true;
- }
- })
- // }
- //修改页面显示判断
- $scope.jry_modify = function () {
- var jry_role = false;
- for (var i = 0; i < $rootScope.user.role.length; i++) {
- if ($rootScope.user.role[i].role == "服务台" && $rootScope.user.role[i].rolecode == "call center") {
- jry_role = true
- }
- }
- if (jry_role) {
- return true
- } else {
- return false
- }
- }
- // 回访操作权限
- for (var obj in $rootScope.user.role) {
- // console.log($rootScope.user.role[obj].rolecode)
- if ($rootScope.user.role[obj].rolecode == 'call center') {
- if ($scope.item.state.id == 1546) {
- $scope.item.huifang = true;
- } else {
- // $scope.item.xiugai = true;
- }
- }
- }
- // 评价操作权限
- $scope.jry_evaluateShow = function () {
- var jry_role = false;
- for (var i = 0; i < $rootScope.user.role.length; i++) {
- if ($rootScope.user.role[i].role == "事件经理" && $rootScope.user.role[i].rolecode == "incident manager") {
- jry_role = true
- }
- }
- // if($scope.item.groupScore!=undefined){
- if ($scope.item.state.id == 1546 && jry_role && $scope.item.groupScore.id == 220) {
- return true
- } else {
- return false
- }
- // }
- }
- $scope.coordination = function () {
- $scope.colobject.grid.appScope.coordination($scope.item);
- }
- $scope.look = function () {
- //$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: $scope.item.id});
- $scope.colobject.grid.appScope.lookFunction($scope.item);
- // console.log('$scope.item='+JSON.stringify($scope.item));
- //$scope.doEdit($scope.item.id);
- }
- $scope.edit = function () {
- // console.log($scope.item)
- $scope.colobject.grid.appScope.selectRowFunction($scope.item);
- // console.log('$scope.item='+JSON.stringify($scope.item));
- // $scope.doEdit($scope.item.id);
- }
- $scope.configuration = function () {
- console.log($scope.item);
- $scope.colobject.grid.appScope.configuration($scope.item)
- }
- $scope.changeCenter = function () {
- $scope.colobject.grid.appScope.changeClick($scope.item);
- }
- $scope.visit = function () {
- $scope.colobject.grid.appScope.visit($scope.item);
- }
- $scope.print = function () { //print
- api_bpm_data.fetchData('incident', $scope.item.id).then(function (res) {
- $scope.colobject.grid.appScope.open(res.data);
- })
- // $scope.colobject.grid.appScope.open($scope.item);
- }
- // 升级
- $scope.upgrade = function () { //print
- $scope.colobject.grid.appScope.upgrade($scope.item);
- // $scope.doEdit($scope.item.id);
- }
- // 转派
- $scope.rotate = function () { //print
- $scope.colobject.grid.appScope.rotate($scope.item);
- // $scope.doEdit($scope.item.id);
- }
- // 协同
- $scope.cooperate = function () { //print
- $scope.colobject.grid.appScope.cooperate($scope.item);
- // $scope.doEdit($scope.item.id);
- }
- // 升级问题
- $scope.problem = function () {
- console.log($scope.item)
- console.log($scope.colobject.grid.appScope)
- $scope.colobject.grid.appScope.problem($scope.item)
- }
- $scope.record = function () { //record
- $scope.colobject.grid.appScope.play($scope.item);
- // $scope.doEdit($scope.item.id);
- }
- $scope.handler = function () {
- $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
- $scope.doComment($scope.item.id);
- }
- $scope.follow = function () {
- $scope.colobject.grid.appScope.followFunction($scope.item);
- }
- //查看
- $scope.toDetail = function (data) {
- //console.log('data='+JSON.stringify(data));
- console.log(data);
- $state.go('app.incident.detail', {
- formKey: 'incident_back',
- pdKey: 'incident',
- dataId: data.id,
- taskId: data.taskId,
- processInstanceId: data.processInstanceId
- });
- };
- // $scope.play = function() {
- // // console.log($scope.item.callID)
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/incident/tpl/audio.html',
- // controller: function($scope, $modalInstance,$sce){
- // $scope.data={
- // "name":"视频",
- // "url":"http://192.168.3.69:8088/recording/recording?callID="+$rootScope.callid
- // };
- // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
- // // $scope.audiourl={url:$sce.trustAsResourceUrl("http://192.168.3.69:8088/recording/recording?callID=218147232")};
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // $modalInstance.close();
- // }
- // });
- // };
- }]);
- //操作按钮
- 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" >' +
- // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>'+
- '<a ng-click="handler()" ng-show="{{item.state.id != 1546 &&!item.handlerUser&&item.tiquPower&&qiangdan}}" class="bianjifont" >抢单</a>' +
- // '<a ng-click="changeCenter()" ng-show="jry_modify()" class="luyinfont">修改</a>' +
- '<a ng-click="edit()" ng-show="{{item.chaozuoPower&&chuli}}" class="bianjifont">处理</a>' +
- '<a ng-click="visit()" ng-show="{{item.huifang&&huifang}}" class="bianjifont">回访</a>' +
- // '<a ng-click="print()" ng-show="dayin" class="bianjifont" >打印</a>' +
- '<a ng-click="toDetail(item)" class="bianjifont" >查看</a>' +
- // '<a ng-click="jry_evaluate()" ng-show="jry_evaluateShow()" class="luyinfont" >评价</a>' +
- // '<a ng-click="record()" ng-show="{{item.listen}}" class="luyinfont" >录音</a>' +
- // '<a ng-click="rotate()" ng-show="{{item.state.id==4}}" class="rotate" >转派</a>' +
- // '<a ng-click="upgrade()" ng-show="{{up&&item.state.id==4&&item.currentRole!=' + "'incident manager'" + '}}" class="upgrade" >升级</a>' +
- // '<a ng-click="problem()" ng-show="{{item.state.id==5&&item.currentRole!=' + "'incident manager'" + '}}" class="upgrade" >问题升级</a>' +
- // '<a ng-click="configuration()" ng-show="{{item.state.id==5}}" class="bianjifont">变更升级</a>' +
- // '<a ng-click="cooperate()" ng-show="{{item.state.id==4}}" class="cooperate" >协同</a>' +
- // '<a ng-click="coordination()" ng-show="{{item.coordination}}" tooltip="添加协同人" tooltip-placement="left"><i class="icon iconfont icon-tianjiarenyuan adduserfont"></i></a>' +
- // '<a class="ui-grid-cell-contents" ng-click="grid.appScope.open(row.entity)" tooltip="打印" tooltip-placement="left"><i class="ti-printer"></i></a>'+
- // '<a ng-click="grid.appScope.play(row.entity)"ng-if="row.entity.callID" tooltip="播放录音" tooltip-placement="left"><i class="ti-microphone"></i></a>'+
- // '<a ng-click="follow()" tooltip="状态跟踪" tooltip-placement="left"><i class="fa fa-location-arrow"></i></a>'+
- '</div></div>'
- };
- });
|