1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261 |
- "use strict";
- /**
- * controller for User Profile Example
- */
- app.controller("integralCtrl", [
- "$rootScope",
- "$scope",
- "$state",
- "$timeout",
- "$interval",
- "$modal",
- "SweetAlert",
- "i18nService",
- "uiGridConstants",
- "uiGridGroupingConstants",
- "Restangular",
- "api_bpm_schedule",
- "api_bpm_data",
- "api_wechatfile",
- "api_configure_data",
- "api_simple",
- "moment",
- function (
- $rootScope,
- $scope,
- $state,
- $timeout,
- $interval,
- $modal,
- SweetAlert,
- i18nService,
- uiGridConstants,
- uiGridGroupingConstants,
- Restangular,
- api_bpm_schedule,
- api_bpm_data,
- api_wechatfile,
- api_configure_data,
- api_simple,
- moment
- ) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = "zh-cn";
- i18nService.setCurrentLang($scope.lang);
- var loginUser = $rootScope.user;
- $scope.xinzeng = false;
- $scope.shanchu = false;
- $scope.bianji = false;
- $scope.zantingzhixing = false;
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "xunjianjihua_xinzeng") {
- $scope.xinzeng = true;
- }
- if (loginUser.menu[i].link == "xunjianjihua_shanchu") {
- $scope.shanchu = true;
- }
- if (loginUser.menu[i].link == "xunjianjihua_bianji") {
- $scope.bianji = true;
- }
- if (loginUser.menu[i].link == "xunjianjihua_zantingzhixing") {
- $scope.zantingzhixing = true;
- }
- }
- $scope.isIncidentManager = false;
- loginUser.role.forEach(v=>{
- if(v.rolecode === 'incident manager'){
- $scope.isIncidentManager = true;
- }
- })
- var defaultFilterData = {
- idx: 0,
- sum: 10,
- };
- var inspectPlanParameter = {
- idx: 0,
- sum: 10,
- operation: "",
- status: "",
- inspection: {
- inspectionTypeDTO: {
- id: "",
- },
- },
- };
- //本地存储
- sessionStorage.inspectPlanParameter = JSON.stringify(inspectPlanParameter);
- $scope.memoryfilterData = {
- idx: 0,
- sum: 10,
- };
- // $scope.isMask = false;
- $scope.gridOptions = {};
- $scope.gridOptions.data = "myData";
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.useExternalFiltering = false;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- // $scope.gridOptions.enableSelectionBatchEvent = true; //使用批量使用事件
- //行鼠标悬浮变色功能
- // $scope.gridOptions.rowTemplate = '<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ng-mouseover="grid.appScope.hoveredIndex = rowRenderIndex" ng-mouseleave="grid.appScope.hoveredIndex = null" ui-grid-one-bind-id-grid="rowRenderIndex + \'-\' + col.uid + \'-cell\'" class="ui-grid-cell" ng-class="{\'ui-grid-row-header-cell\': col.isRowHeader, \'your-hover-class\': grid.appScope.hoveredIndex === rowRenderIndex}" role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell></div>';
- // $scope.gridOptions.rowTemplate =
- // '<div ng-dblclick="grid.appScope.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.gridOptions.isRowSelectable = function (row,i) {
- console.log(row);
- if (row.entity.auditState.value == 0) {
- return true;
- } else {
- return false;
- }
- };
- $scope.transfer = function (status) {
- if (status === "正常") {
- return "执行中";
- } else if (status === "停止") {
- return "暂停中";
- }
- };
- $scope.gridOptions.columnDefs = [
- {
- name: "item",
- displayName: "序号",
- width: 50,
- enableFiltering: false,
- },
- {
- name: "description",
- displayName: "故障描述",
- width: "10%",
- enableFiltering: true,
- cellTemplate:
- '<div class="ui-grid-cell-contents">{{row.entity.incident?row.entity.incident.description:""}}</div>',
- },
- {
- name: "category",
- displayName: "故障现象",
- width: "10%",
- enableFiltering: false,
- cellTemplate:
- '<div class="ui-grid-cell-contents">{{row.entity.incident?row.entity.incident.category.category:""}}</div>',
- },
- {
- name: "handlerUserName",
- displayName: "处理人",
- width: "140",
- enableFiltering: false,
- },
- {
- name: "planEndTime",
- displayName: "登记时间",
- width: "200",
- enableFiltering: false,
- cellTemplate:
- '<div class="ui-grid-cell-contents">{{row.entity.addTime | date:"yyyy-MM-dd HH:mm:ss"}}</div>',
- },
- {
- name: "sourceScore",
- displayName: "原工时",
- width: "109",
- enableFiltering: false,
- },
- {
- name: "currentScore",
- displayName: "最终工时",
- width: "11%",
- enableFiltering: false,
- },
- {
- name: "updateReason",
- displayName: "升级原因",
- width: "12%",
- enableFiltering: false,
- },
- {
- name: "auditState.desc",
- displayName: "审核状态",
- width: "15%",
- enableFiltering: false,
- },
- {
- minWidth: "230",
- name: "操作",
- enableFiltering: false,
- cellTemplate:
- '<div class="cl-effect-1 ui-grid-cell-contents pull-left">' +
- // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="编辑" tooltip-placement="right"><i class="icon iconfont icon-bianji bianjifont"></i></a>' +
- '<a ng-click="grid.appScope.toDetail(row.entity.incident)" class="bianjifont">查看事件</a>' +
- '<a ng-click="grid.appScope.toAudit(row.entity)" class="bianjifont" ng-if="grid.appScope.isIncidentManager&&row.entity.auditState.value == 0">审核</a>' +
- // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" ng-show="{{(row.entity.status.name==\'正常\'||row.entity.status.name==\'停止\')&&grid.appScope.bianji}}" class="bianjifont">编辑</a>' +
- // '<a ng-click="grid.appScope.runFunction(row.entity)" tooltip={{row.entity.runStatus}} tooltip-placement="left"><i class={{row.entity.style}}/></a>' +
- // '<a ng-click="grid.appScope.runFunction(row.entity)" ng-show="{{row.entity.status.name==\'正常\'&&grid.appScope.zantingzhixing}}" class="bianjifont">执行中</a>' +
- // '<a ng-click="grid.appScope.runFunction(row.entity)" ng-show="{{row.entity.status.name==\'停止\'&&grid.appScope.zantingzhixing}}" class="bianjifont">暂停中</a>' +
- "</div>",
- },
- // { name: 'planTime2', displayName: '截止时间', width: 160, enableFiltering: false },
- ];
- $scope.transferTime = function (time) {
- return moment(time).format("YYYY-MM-DD HH:mm");
- };
- //新增数据
- $scope.addData = function () {
- $state.go("app.inspection.editor", {
- formKey: "inspectionform",
- service: "api_bpm_data",
- });
- };
- $scope.inspectdata = {};
- //跳转到编辑列表
- $scope.selectRowFunction = function (data) {
- var datas = delete data.item;
- datas = delete data.style;
- datas = delete data.runStatus;
- var filedata = {
- model: {
- incidentIntegral: data,
- },
- };
- $state.go("app.inspection.editor", {
- formKey: "inspectionform",
- service: "api_bpm_data",
- model: JSON.stringify(filedata),
- });
- };
- // 批量审核liaomingming
- $scope.batchReview = function(){
- SweetAlert.swal({
- title: "提示",
- text: "您是需要批量审核通过吗?",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- closeOnConfirm: true,
- closeOnCancel: true
- }, function (isConfirm) {
- if (isConfirm) {
- console.log($scope.selected.items);
- api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
- var auditState = res.find(v=>v.value == 1);
- var postData = angular.copy($scope.selected.items);
- postData.forEach(v=>{
- v.auditState = auditState;
- })
- api_simple.addListData('incidentIntegral', postData).then(function (response) {
- console.log(response)
- if (response.status == 200) {
- SweetAlert.swal({
- title: "审核通过!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- $scope.refreshData('expand-right', $scope.fileData);
- } else {
- SweetAlert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- })
- }
- });
- }
- //跳转到查看列表
- $scope.seeFunction = function (data) {
- var filedata = {
- model: {
- incidentIntegral: data,
- },
- };
- $state.go("app.inspection.form", {
- formKey: "inspection__detailform",
- service: "api_bpm_data",
- model: JSON.stringify(filedata),
- });
- };
- //跳转到查看列表
- $scope.lookFunction = function (data) {
- var filedata = {
- model: {
- incidentIntegral: data,
- },
- };
- $state.go("app.inspection.form", {
- formKey: "inspection__detailform",
- service: "api_bpm_data",
- model: JSON.stringify(filedata),
- });
- };
- //巡检暂停/恢复
- $scope.runFunction = function (data) {
- var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- var upData = {};
- upData.id = data.id;
- upData.operation = 1;
- var modalInstance = $modal.open({
- // templateUrl: 'assets/views/inspect/changRun.html',
- templateUrl: "assets/views/delete.html",
- // size: "sm",
- controller: function ($scope, $modalInstance) {
- $scope.isRunFunction = true;
- var status = "";
- if (data.status.name == "正常") {
- $scope.title = "暂停巡检计划";
- $scope.connect = "确定要暂停该巡检计划?";
- // $scope.textLog = "是否暂停该巡检计划";
- } else if (data.status.name == "停止") {
- $scope.title = "开始巡检计划";
- $scope.connect = "确定要开始该巡检计划?";
- // $scope.textLog = "是否开始该巡检计划";
- }
- $scope.ok = function () {
- // var groupdata = "123";
- // $modalInstance.dismiss('cancel');
- if (data.status.name == "正常") {
- upData.status = "停止";
- // data.style = "fa fa-pause";
- } else if (data.status.name == "停止") {
- upData.status = "正常";
- // data.style = "fa fa-play";
- }
- sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
- // $modalInstance.close(upData);
- $modalInstance.close(data);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- },
- size: "sm",
- });
- modalInstance.result.then(function (result) {
- if (result) {
- // if(result.status=="停止"){
- // result.status={"id":$scope.statusData[1].id}
- // }else{
- // result.status={"id":$scope.statusData[2].id}
- // }
- // var upData = {
- // "inspection":{
- // "id": result.id,
- // "operation": result.operation,
- // "status": result.status
- // }
- // };
- if (result.status.value == "1") {
- result.status.id = $scope.statusData[1].id;
- } else if (result.status.value == "2") {
- result.status.id = $scope.statusData[0].id;
- }
- var toData = {
- inspection: result,
- };
- api_bpm_data.updData("inspection", toData).then(
- function (response) {
- var myData = Restangular.stripRestangular(response);
- if (myData.status == 200) {
- var showData = {
- idx: filterData.idx,
- sum: filterData.sum,
- inspection: {
- inspectionTypeDTO: {
- id: "",
- },
- },
- };
- if (
- filterData.inspection &&
- filterData.inspection.inspectionTypeDTO &&
- filterData.inspection.inspectionTypeDTO.id
- ) {
- showData.inspection.inspectionTypeDTO.id =
- filterData.inspection.inspectionTypeDTO.id;
- } else {
- showData.inspection.inspectionTypeDTO.id = -1;
- }
- $scope.refreshData("expand-right", $scope.fileData);
- }
- },
- function () {
- // $scope.ldloading[style.replace('-', '_')] = false;
- }
- );
- }
- });
- };
- // $scope.newincident = function(data) {
- // $state.go('app.incident.editor', {});
- // };
- //行删除
- $scope.removeData = function () {
- console.log($scope.selected.items);
- var modalInstance = $modal.open({
- templateUrl: "assets/views/delete.html",
- controller: function ($scope, $modalInstance) {
- // $scope.textLog = "是否删除巡检计划";
- $scope.title = "巡检计划删除";
- $scope.connect = "确定要删除巡检计划?";
- $scope.ok = function () {
- $modalInstance.close("start");
- };
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- },
- size: "sm",
- });
- modalInstance.result.then(
- function (result) {
- if (result) {
- if ($scope.selected.items.length != 0) {
- $rootScope.isMask = true;
- }
- var rmvList = [];
- angular.forEach($scope.selected.items, function (item) {
- rmvList.push(item.id);
- });
- if (rmvList.length > 0) {
- api_bpm_data
- .rmvData("inspection", rmvList)
- .then(function (response) {
- if (response.status == 200) {
- $rootScope.isMask = false;
- SweetAlert.swal(
- {
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF",
- },
- function () {
- $scope.myData = _.reject($scope.myData, function (o) {
- return _.includes(rmvList, o.id);
- });
- $scope.selected = {
- items: [],
- };
- }
- );
- $scope.gridApi.selection.clearSelectedRows();
- var filterData = JSON.parse(
- sessionStorage.inspectPlanParameter
- );
- var showData = {
- idx: filterData.idx,
- sum: filterData.sum,
- inspection: {
- inspectionTypeDTO: {
- id: "",
- },
- },
- };
- if (
- filterData.inspection &&
- filterData.inspection.inspectionTypeDTO &&
- filterData.inspection.inspectionTypeDTO.id
- ) {
- showData.inspection.inspectionTypeDTO.id =
- filterData.inspection.inspectionTypeDTO.id;
- } else {
- showData.inspection.inspectionTypeDTO.id = -1;
- }
- $scope.refreshData("expand-right", $scope.fileData);
- //取消遮罩层
- // $scope.isMask = false;
- } else {
- $rootScope.isMask = false;
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error",
- });
- }
- });
- }
- }
- },
- function () {
- // $scope.ldloading[style.replace('-', '_')] = false;
- }
- );
- };
- $scope.selected = {
- items: [],
- };
- $scope.editted = {
- items: [],
- };
- $scope.testRow = [];
- $scope.gridOptions.onRegisterApi = function (gridApi) {
- //导入gridApi对象
- $scope.gridApi = gridApi;
- //分页选项
- gridApi.pagination.on.paginationChanged(
- $scope,
- function (newPage, pageSize) {
- var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- var filtersData = {};
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- $scope.pageNum = $scope.gridApi.pagination.getPage() - 1;
- // console.log(pp);
- filterData.idx = $scope.pageNum;
- $scope.fileData.idx = newPage - 1;
- $scope.fileData.sum = pageSize;
- sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
- $scope.refreshData("expand-right", $scope.fileData);
- }
- );
- //勾选行事件
- gridApi.selection.on.rowSelectionChanged($scope, function (data) {
- if (data.isSelected) {
- $scope.selected.items.push(data.entity);
- } else {
- //objs:需要遍历的集合 data:遍历时当前的数据 index:遍历时当前索引
- //array:需要遍历的集合,每次遍历时都会把objs原样的传一次。
- //angular.forEach(objs, function(data,index,array)
- angular.forEach(
- $scope.selected.items,
- function (ObjIndex, index, destObj) {
- // console.log(ObjIndex);
- // console.log(index);
- // console.log(destObj);
- if (ObjIndex.id == data.entity.id) {
- destObj.splice(index, 1);
- }
- }
- );
- }
- });
- //批量全选
- gridApi.selection.on.rowSelectionChangedBatch(
- $scope,
- function (rows, event) {
- // if ($scope.selected.items.length != 0) {
- // $scope.selected.items = [];
- angular.forEach(rows, function (ObjIndex, index, destObj) {
- if (ObjIndex.isSelected) {
- $scope.selected.items.push(ObjIndex.entity);
- } else {
- $scope.selected.items = [];
- // $scope.selected.items.splice(index, 1);
- }
- });
- // } else {
- // }
- // $scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
- // if ($scope.selected.items.length == 0) {
- // $scope.selected.items = $scope.mySelectedRows;
- // } else if ($scope.mySelectedRows.length == 0) {
- // for (var i = 0; i < $scope.selected.items.length; i++) {
- // for (var j = 0; j < rows.length; j++) {
- // if ($scope.selected.items[i].id == rows[j].entity.id) {
- // $scope.selected.items.splice(i, 1);
- // }
- // }
- // }
- // } else {
- // angular.forEach($scope.mySelectedRows, function(item) {
- // $scope.selected.items.push(item);
- // });
- // }
- }
- );
- //列过滤事件
- gridApi.core.on.filterChanged($scope, function () {
- var grid = this.grid;
- var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- angular.forEach(grid.columns, function (item) {
- if (item.enableFiltering) {
- if (
- angular.isDefined(item.filters[0].term) &&
- item.filters[0].term != ""
- ) {
- if (angular.isUndefined(filterData["inspection"])) {
- filterData["inspection"] = {};
- }
- filterData["inspection"]["title"] = item.filters[0].term;
- }
- }
- });
- sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
- $scope.refreshData("expand-right", filterData);
- });
- };
- // //刷新按钮
- // $scope.reload = function() {
- // var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- // var showData = {
- // "idx": filterData.idx,
- // "sum": filterData.sum,
- // "inspection": {
- // "inspectionTypeDTO": {
- // "id": ""
- // }
- // }
- // }
- // if (filterData.inspection && filterData.inspection.inspectionTypeDTO && filterData.inspection.inspectionTypeDTO.id) {
- // showData.inspection.inspectionTypeDTO.id = filterData.inspection.inspectionTypeDTO.id
- // } else {
- // showData.inspection.inspectionTypeDTO.id = -1
- // }
- // $scope.refreshData('expand-right', showData);
- // }
- //审核
- $scope.toAudit = function (data) {
- $modal.open({
- templateUrl: 'assets/views/incident/tpl/toAudit.tpl.html',
- controller: function ($scope, scope, $modalInstance, modelData, currentUserId, Alert, api_wechatfile,api_bpm_data) {
- $scope.msg = `由${data.handlerUserName}处理的事件由工时${data.sourceScore}改为工时${data.currentScore},发起原因为:${data.updateReason||''}`;
- $scope.ok = function () {
- api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
- var auditState = res.find(v=>v.value == 1);
- var postData = {
- incidentIntegral: {
- id:modelData.id,
- incidentId:modelData.incidentId,
- auditState:auditState,
- handlerUser:modelData.handlerUser,
- handlerUserName:modelData.handlerUserName,
- sourceScore:modelData.sourceScore,
- currentScore:modelData.currentScore,
- updateReason:modelData.updateReason||undefined,
- }
- }
- $modalInstance.close('success');
- api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
- console.log(response)
- if (response.status == 200) {
- Alert.swal({
- title: "审核通过!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- scope.refreshData('expand-right', $scope.fileData);
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- })
- }
- // 调整工时
- $scope.time = function(){
- $modalInstance.close('success');
- $modal.open({
- templateUrl: 'assets/views/incident/tpl/toAuditTime.tpl.html',
- controller: function ($scope, $modalInstance, modelData, currentUserId, Alert,api_wechatfile,api_bpm_data) {
- console.log(modelData,loginUser);
- $scope.searchList = {time:''};
- $scope.list = [];
- api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
- $scope.list = res;
- })
- $scope.ok = function () {
- if (!$scope.searchList.time){
- Alert.swal({
- title: "操作失败",
- text: "请填写工时!",
- type: "error"
- });
- return;
- }
- api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
- var auditState = res.find(v=>v.value == 1);
- var postData = {
- incidentIntegral: {
- id:modelData.id,
- incidentId:modelData.incidentId,
- auditState:auditState,
- handlerUser:modelData.handlerUser,
- handlerUserName:modelData.handlerUserName,
- sourceScore:modelData.sourceScore,
- currentScore:modelData.currentScore,
- updateReason:modelData.updateReason||undefined,
- }
- }
- $modalInstance.close('success');
- api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
- console.log(response)
- if (response.status == 200) {
- Alert.swal({
- title: "审核通过!",
- confirmButtonColor: "#007AFF",
- type: "success"
- });
- scope.refreshData('expand-right', $scope.fileData);
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- })
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- modelData: function () {
- return data;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_wechatfile: function () {
- return api_wechatfile;
- },
- api_bpm_data: function () {
- return api_bpm_data;
- },
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- },
- modelData: function () {
- return data;
- },
- currentUserId: function () {
- return loginUser.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_wechatfile: function () {
- return api_wechatfile;
- },
- api_bpm_data: function () {
- return api_bpm_data;
- }
- }
- });
- };
- //查看
- $scope.toDetail = function (data) {
- console.log(data,$rootScope.isFuwutai);
- if($rootScope.isFuwutai){
- //角色是服务台人员
- $state.go('app.incident.detail', {
- formKey: 'incident_back',
- pdKey: 'incident',
- dataId: data.id,
- taskId: data.taskId,
- processInstanceId: data.processInstanceId
- });
- }else{
- window.open(location.origin+'/#/app/incident/detail/incident_back/incident/'+data.id+'/'+data.taskId+'/'+data.processInstanceId+'//');
- }
- };
- //重置按钮
- $scope.reload = function () {
- // var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- // var data={
- // "idx":filterData.idx,
- // "sum":filterData.sum
- // }
- // $scope.inspectdata={};
- if(!$scope.isIncidentManager){
- $scope.fileData.incidentIntegral = {handlerUser:$rootScope.user.id}
- }else{
- $scope.fileData.incidentIntegral = {};
- }
- $scope.try_async_load();
- $scope.refreshData("expand-right", $scope.fileData);
- };
- //数据刷新
- $scope.refreshData = function (style, filterData) {
- $scope.ldloading[style.replace("-", "_")] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- var filterDataClone = angular.copy(filterData)
- if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.startTime){
- filterDataClone.incidentIntegral.startTime = moment(filterDataClone.incidentIntegral.startTime).format('YYYY-MM-DD 00:00:00');
- }
- if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.endTime){
- filterDataClone.incidentIntegral.endTime = moment(filterDataClone.incidentIntegral.endTime).format('YYYY-MM-DD 23:59:59');
- }
- if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.handlerUser){
- filterDataClone.incidentIntegral.handlerUser = filterDataClone.incidentIntegral.handlerUser.id;
- }
- if(!$scope.isIncidentManager){
- filterDataClone.incidentIntegral.handlerUser = $rootScope.user.id;
- }
- api_bpm_data.fetchDataList("incidentIntegral", filterDataClone).then(
- function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- if (angular.isArray(myData.list)) {
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]["item"] =
- i + 1 + filterData.idx * filterData.sum;
- if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
- $scope.myData[i].percent = (
- ($scope.myData[i].completed * 100) /
- ($scope.myData[i].doing + $scope.myData[i].completed)
- ).toFixed(1);
- } else if ($scope.myData[i].completed == 0) {
- $scope.myData[i].percent = "0.0";
- } else {
- $scope.myData[i].percent = "0.0";
- }
- }
- console.log($scope.myData);
- for (var i = 0; i < $scope.myData.length; i++) {
- if ($scope.myData[i].status == "正常") {
- $scope.myData[i].style = "fa fa-play";
- } else if ($scope.myData[i].status == "停止") {
- $scope.myData[i].style = "fa fa-pause";
- }
- $scope.myData[i].runStatus = $scope.transfer(
- $scope.myData[i].status
- );
- }
- } else {
- SweetAlert.swal({
- title: "数据为空",
- text: myData.data,
- type: "warning",
- });
- }
- $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)) {
- filterData = defaultFilterData;
- }
- var filterDataClone = angular.copy(filterData)
- if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.startTime){
- filterDataClone.incidentIntegral.startTime = moment(filterDataClone.incidentIntegral.startTime).format('YYYY-MM-DD 00:00:00');
- }
- if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.endTime){
- filterDataClone.incidentIntegral.endTime = moment(filterDataClone.incidentIntegral.endTime).format('YYYY-MM-DD 23:59:59');
- }
- if(filterDataClone.incidentIntegral&&filterDataClone.incidentIntegral.handlerUser){
- filterDataClone.incidentIntegral.handlerUser = filterDataClone.incidentIntegral.handlerUser.id;
- }
- if(!$scope.isIncidentManager){
- filterDataClone.incidentIntegral.handlerUser = $rootScope.user.id;
- }
- // $scope.myData = [];
- api_bpm_data.fetchDataList("incidentIntegral", filterDataClone).then(
- function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- if (angular.isArray(myData.list)) {
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]["item"] =
- i + 1 + filterData.idx * filterData.sum;
- if ($scope.myData[i].doing + $scope.myData[i].completed != 0) {
- $scope.myData[i].percent = (
- ($scope.myData[i].completed * 100) /
- ($scope.myData[i].doing + $scope.myData[i].completed)
- ).toFixed(1);
- } else if ($scope.myData[i].completed == 0) {
- $scope.myData[i].percent = "0.0";
- } else {
- $scope.myData[i].percent = "0.0";
- }
- }
- console.log($scope.myData);
- for (var i = 0; i < $scope.myData.length; i++) {
- if ($scope.myData[i].status == "正常") {
- $scope.myData[i].style = "fa fa-play";
- } else if ($scope.myData[i].status == "停止") {
- $scope.myData[i].style = "fa fa-pause";
- }
- $scope.myData[i].runStatus = $scope.transfer(
- $scope.myData[i].status
- );
- }
- } else {
- SweetAlert.swal({
- title: "数据为空",
- text: myData.data,
- type: "warning",
- });
- }
- $scope.ldloading[style.replace("-", "_")] = false;
- },
- function () {
- $scope.ldloading[style.replace("-", "_")] = false;
- }
- );
- };
- $scope.ldloading = {};
- //树形控件点击事件
- $scope.my_tree_handler = function (branch) {
- var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- filterData.inspection.inspectionTypeDTO.id = branch.id;
- sessionStorage.inspectPlanParameter = JSON.stringify(filterData);
- var showData = {
- idx: filterData.id,
- sum: filterData.sum,
- inspection: {
- inspectionTypeDTO: {
- id: branch.id,
- },
- },
- };
- // $scope.refreshData('expand-right', showData);
- };
- $scope.fileData = {
- idx: 0,
- sum: 10,
- incidentIntegral: {},
- };
- $scope.onFilterCallback = function (data) {
- $scope.fileData.inspection.inspectionTypeDTO = {
- id: data.id,
- };
- };
- $scope.inspecttype = {};
- $scope.searchinspe = function (item) {
- $scope.refreshData("expand-right", $scope.fileData);
- };
- //树形控件加载
- $scope.my_tree = {};
- $scope.try_async_load = function () {
- $scope.my_data = [];
- $scope.doing_async = true;
- api_bpm_data
- .fetchDataList("inspectionType", {
- idx: 0,
- sum: 1000,
- })
- .then(function (response) {
- if (response.status == 200) {
- var data = response.list;
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- if (data[i].parent && data[i].parent.id != 0) {
- object.parent = data[i].parent.id;
- }
- object.label = data[i].type;
- objects.push(object);
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.tree_data = angular.copy($scope.my_data);
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- // return $scope.my_tree.expand_all()
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error",
- });
- }
- });
- };
- 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];
- //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;
- }
- // 获取状态
- $scope.getStatusDictroy = function () {
- var data = {
- key: "incident_integral_state",
- type: "list",
- };
- api_wechatfile.getDictionary(data).then(function (res) {
- $scope.statusData = res;
- });
- };
- $scope.getStatusDictroy();
- // 获取执行人
- $scope.getExecuteUser = function () {
- api_configure_data
- .fetchDataList("user", {
- idx: 0,
- sum: 1000,
- user: {
- roledata: {
- rolecode: "inspectman",
- },
- simple: true,
- engineer: 1,
- },
- })
- .then(function (res) {
- $scope.executeUserData = res.list;
- });
- };
- $scope.getExecuteUser();
- // 获取处理人
- $scope.getCreateUser = function (keyword = '') {
- api_configure_data
- .fetchDataList("user", {
- idx: 0,
- sum: 1000,
- "user": {
- "name": keyword,
- 'selectType': "pinyin_qs",
- engineer: 1,
- }
- })
- .then(function (res) {
- $scope.createUserData = res.list;
- });
- };
- $scope.getCreateUser();
- $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;
- };
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- return list;
- }
- $scope.refresh = function () {
- var jry_filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- var intervalData = {};
- if ($scope.inspectdata.type) {
- $scope.inspectdata.inspectionTypeDTO = $scope.inspectdata.type.id;
- }
- if ($scope.inspectdata.createTime) {
- $scope.inspectdata.createTime = moment(
- $scope.inspectdata.createTime
- ).format("YYYY-MM-DD");
- }
- intervalData.idx = jry_filterData.idx;
- intervalData.sum = jry_filterData.sum;
- intervalData.inspection = $scope.inspectdata;
- $scope.refreshData("expand-right", intervalData);
- };
- $scope.try_async_load();
- $scope.refreshData("expand-right", $scope.fileData);
- $scope.timer = $interval(function () {
- $scope.refreshData2("expand-right", $scope.fileData);
- }, $rootScope.refreshTime);
- $scope.$on("$destroy", function () {
- $interval.cancel($scope.timer);
- });
- },
- ]);
- app.factory("inspectListMobileCtrlTree", [
- "api_bpm_data",
- function (api_bpm_data) {
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {};
- var root = null;
- var parentNode = null;
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- datum.children = [];
- idToNodeMap[datum.id] = datum;
- if (typeof datum.parent === "undefined" || datum.parent == null) {
- root = datum;
- treeMap[datum.id] = root;
- } else {
- parentNode = idToNodeMap[datum.parent];
- delete datum.parent;
- 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;
- }
- var forEachEelement = function forEachEelement(response) {
- var objects = [];
- angular.forEach(response.list, function (ObjIndex, index, destObj) {
- var object = {};
- object.id = ObjIndex.id;
- object.label = ObjIndex.type;
- if (ObjIndex.parent && ObjIndex.parent.id != 0) {
- object.parent = ObjIndex.parent.id;
- }
- if (ObjIndex.formUiEdit) {
- object.formUiEdit = ObjIndex.formUiEdit;
- }
- if (ObjIndex.formUiName) {
- object.formUiName = ObjIndex.formUiName;
- }
- if (ObjIndex.processKey) {
- object.processKey = ObjIndex.processKey;
- }
- if (ObjIndex.formUiStart) {
- object.formUiStart = ObjIndex.formUiStart;
- }
- objects.push(object);
- });
- var my_data = convertParentToChildList(objects);
- var tree_data = angular.copy(my_data);
- return {
- my_data: my_data,
- tree_data: tree_data,
- };
- };
- return forEachEelement;
- },
- ]);
|