12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259 |
- "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,
- },
- })
- .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"
- }
- })
- .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;
- },
- ]);
|