123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257 |
- "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.incidentDetail', {
- id: data.id,
- });
- }else{
- window.open(location.origin+'/#/app/incident/incidentDetail/'+data.id);
- }
- };
- //重置按钮
- $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;
- },
- ]);
|