reServiceCtrl.js 6.8 KB

1
  1. app.controller("reServiceManagerCtrl",["$rootScope","$scope","i18nService","$state","$timeout","$interval","SweetAlert","$modal","FileUploader","i18nService","uiGridConstants","uiGridGroupingConstants","Restangular","api_user_data","api_solution","api_bpm_domain","api_bpm_data",function(e,t,a,r,i,n,o,s,d,a,c,l,p,m,f,u,g){function y(e,t){for(var a={},r=null,i=null,n=0;n<e.length;n++){var o=e[n];o.children=[],a[o.id]=o,"undefined"==typeof o.parent||null==o.parent?(r=o,t[o.id]=r):(i=a[o.parent],delete o.parent,i.children.push(o))}return r}function h(e){var t={},a=[];return y(e,t),angular.forEach(t,function(e){a.push(e)}),a}t.langs=a.getAllLangs(),t.lang="zh-cn",a.setCurrentLang(t.lang);var S=e.user;t.gridOptions={},t.gridOptions.data="myData",t.gridOptions.enableColumnResizing=!0,t.gridOptions.enableFiltering=!1,t.gridOptions.enableGridMenu=!1,t.gridOptions.enableRowSelection=!0,t.gridOptions.showGridFooter=!0,t.gridOptions.showColumnFooter=!1,t.gridOptions.fastWatch=!0,t.gridOptions.useExternalPagination=!0,t.gridOptions.paginationPageSizes=[10,20,50,100],t.gridOptions.paginationPageSize=10,t.gridOptions.multiSelect=!0,t.gridOptions.rowIdentity=function(e){return e.id},t.gridOptions.getRowIdentity=function(e){return e.id},t.transferTime=function(e){return moment(e).format("YYYY-MM-DD ")},t.transferStatus=function(e){},t.gridOptions.columnDefs=[{name:"操作",width:100,cellTemplate:'<div class="links cl-effect-1" style="height:27px;line-height:27px;"><a ng-click="grid.appScope.lookReService(row.entity)" tooltip="查看" tooltip-placement="right"><i class="ti-eye"></i></a><a ng-show="{{!row.entity.state==1}}" ng-click="grid.appScope.editorReService(row.entity)" ng-if="!row.entity.state" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"/></a></div>'},{name:"category.recate",displayName:"服务分类",width:"15%"},{name:"requester.name",displayName:"申请人",width:"7%"},{name:"excuteUser.name",displayName:"受理人",width:"8%"},{name:"startDate",displayName:"登记时间",width:"15%"},{name:"requester.areaDTO.area",displayName:"申请区域",width:"10%"},{name:"requester.placeDTO.place",displayName:"地点",width:"10%"},{name:"stateName",displayName:"状态",width:"7%"}];var v={assignee:S.id,idx:0,sum:10,status:""},U={assignee:S.id,idx:0,sum:10,status:""};sessionStorage.reServiceParameter=JSON.stringify(v),t.addData=function(){var e=s.open({templateUrl:"assets/views/reService/changRun.html",controller:["$scope","$modalInstance","api_user_data","api_solution","reServiceListMobileCtrlTree",function(e,t,a,r,i){e.isAddFunction=!0,e.treeBranch={},e.my_tree_handler=function(t){var a={},r={};e.treeBranch=t,r.status=t.id,t.formUiEdit&&(a.formUiEdit=t.formUiEdit),t.formUiName&&(a.formUiName=t.formUiName),t.processKey&&(a.processKey=t.processKey),t.formUiStart&&(a.formUiStart=t.formUiStart),r.idx=0,angular.extend(r,a)},e.my_data=[],e.tree_data=[],e.my_tree={},e.try_async_load=function(){g.fetchDataList("requestcategory",{idx:0,sum:1e3}).then(function(t){var a=i(t);e.my_data=a.my_data,e.tree_data=a.tree_data})},e.try_async_load(),e.ok=function(){var a=e.treeBranch;e.treeBranch.formUiStart?t.close(a):t.close()},e.cancel=function(){t.dismiss("cancel")}}],size:"sm"});e.result.then(function(e){if(e){var t=e;if(t.formUiEdit)var a=t.formUiEdit;if(t.formUiName)var i=t.formUiName;if(t.processKey)var n=t.processKey;if(t.formUiStart)var s=t.formUiStart;r.go("app.reService.newService",{pdKey:n,formUiEdit:a,formUiName:i,formUiStart:s,userId:t.status})}else o.swal({title:"当前服务类型不可新建",type:"warning"})})},t.editorReService=function(e){r.go("app.reService.editor",{taskId:e.taskId,processInstanceId:e.processInstanceId,pdKey:e.category.processKey,formUiEdit:e.category.formUiEdit})},t.lookReService=function(e){r.go("app.reService.detail",{formKey:e.category.formUiName,dataId:e.id,taskId:e.taskId,processInstanceId:e.processInstanceId,pdKey:e.category.processKey})},t.reload=function(){var e=JSON.parse(sessionStorage.reServiceParameter);t.refreshListData("expand-right",e)},t.gridOptions.onRegisterApi=function(e){t.gridApi=e,e.pagination.on.paginationChanged(t,function(e,a){var r=JSON.parse(sessionStorage.reServiceParameter);r.idx=e-1,r.sum=a,t.refreshListData("expand-right",r)}),e.selection.on.rowSelectionChanged(t,function(e){t.selected.item=e.entity})},this.selectRowFunction=function(e){},t.onChange=function(e){var a=JSON.parse(sessionStorage.reServiceParameter);a.searchType=e,sessionStorage.reServiceParameter=JSON.stringify(a),t.refreshListData("expand-right",a)},t.my_tree_handler=function(e){var a=JSON.parse(sessionStorage.reServiceParameter);a.status=e.id,e.formUiEdit&&(a.formUiEdit=e.formUiEdit),e.formUiName&&(a.formUiName=e.formUiName),e.processKey&&(a.processKey=e.processKey),e.formUiStart&&(a.formUiStart=e.formUiStart),sessionStorage.reServiceParameter=JSON.stringify(a),t.refreshListData("expand-right",a)},t.ldloading={},t.refreshListData=function(e,a){t.ldloading[e.replace("-","_")]=!0,angular.isUndefined(a)&&(a=U);var r={assignee:a.assignee,idx:a.idx,searchType:a.searchType,status:a.status,sum:a.sum};t.myData=[],g.fetchServiceTasks(a.status,r).then(function(a){var r=p.stripRestangular(a);t.gridOptions.totalItems=r.resultCount,angular.isArray(r.data)?t.myData=r.data:o.swal({title:"数据为空",text:r.data,type:"warning"}),t.ldloading[e.replace("-","_")]=!1},function(){t.ldloading[e.replace("-","_")]=!1})};var _;t.my_data=[],t.tree_data=[],t.my_tree=_={},t.my_tree=_={},t.try_async_load=function(){t.my_data=[],t.doing_async=!0,g.fetchDataList("requestcategory",{idx:0,sum:1e3}).then(function(e){if(200==e.status){var a=[];angular.forEach(e.list,function(e,t,r){var i={};i.id=e.id,i.label=e.recate,e.parent&&0!=e.parent.id&&(i.parent=e.parent.id),e.formUiEdit&&(i.formUiEdit=e.formUiEdit),e.formUiName&&(i.formUiName=e.formUiName),e.processKey&&(i.processKey=e.processKey),e.formUiStart&&(i.formUiStart=e.formUiStart),a.push(i)}),t.my_data=h(a),t.tree_data=angular.copy(t.my_data),t.my_data.length>0&&(t.doing_async=!1)}else o.swal({title:"系统错误!",text:"请刷新重试!",type:"error"})})},t.refreshListData("expand_right"),t.try_async_load()}]),app.factory("reServiceListMobileCtrlTree",["api_bpm_data",function(e){function t(e,t){for(var a={},r=null,i=null,n=0;n<e.length;n++){var o=e[n];o.children=[],a[o.id]=o,"undefined"==typeof o.parent||null==o.parent?(r=o,t[o.id]=r):(i=a[o.parent],delete o.parent,i.children.push(o))}return r}function a(e){var a={},r=[];return t(e,a),angular.forEach(a,function(e){r.push(e)}),r}var r=function(e){var t=[];angular.forEach(e.list,function(e,a,r){var i={};i.id=e.id,i.label=e.recate,e.parent&&0!=e.parent.id&&(i.parent=e.parent.id),e.formUiEdit&&(i.formUiEdit=e.formUiEdit),e.formUiName&&(i.formUiName=e.formUiName),e.processKey&&(i.processKey=e.processKey),e.formUiStart&&(i.formUiStart=e.formUiStart),t.push(i)});var r=a(t),i=angular.copy(r);return{my_data:r,tree_data:i}};return r}]);