123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952 |
- 'use strict';
- /**
- * controller for User Profile Example
- */
- app.controller('inspectPlanCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_schedule", "api_bpm_data", "api_wechatfile", "api_configure_data", "moment", function ($rootScope, $scope, $state, $timeout, $interval, $modal, SweetAlert, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_schedule, api_bpm_data, api_wechatfile, api_configure_data, 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
- }
- }
- 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.transfer = function (status) {
- if (status === "正常") {
- return "执行中"
- } else if (status === "停止") {
- return "暂停中"
- }
- }
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 50,
- enableFiltering: false
- },
- {
- name: 'title',
- displayName: '计划主题',
- width: '10%',
- enableFiltering: true
- },
- {
- name: 'planStrategy.name',
- displayName: '执行策略',
- width: '10%',
- enableFiltering: false
- },
- {
- name: 'planStartTime',
- displayName: '计划开始时间',
- width: '140',
- enableFiltering: false,
- cellTemplate: '<div class="ui-grid-cell-contents">{{row.entity.planStartTime.length>16?grid.appScope.transferTime(row.entity.planStartTime):row.entity.planStartTime}}</div>'
- },
- {
- name: 'planEndTime',
- displayName: '计划结束时间',
- width: '140',
- enableFiltering: false,
- cellTemplate: '<div class="ui-grid-cell-contents">{{row.entity.planEndTime.length>16?grid.appScope.transferTime(row.entity.planEndTime):row.entity.planEndTime}}</div>'
- },
- {
- name: 'dictionary.name',
- displayName: '巡检类型',
- width: '109',
- enableFiltering: false
- },
- {
- name: 'executeUser.name',
- displayName: '执行人/组',
- width: '11%',
- enableFiltering: false,
- cellTemplate: '<div class="ui-grid-cell-contents"><span ng-if="row.entity.dictionary.value == 1&&row.entity.executeUser">{{row.entity.executeUser.name }}</span><span ng-if="row.entity.dictionary.value == 3&&row.entity.group">{{row.entity.group.groupName }}</span><span ng-if="row.entity.dictionary.value == 4">无</span></div>'
- },
- {
- name: 'status.name',
- displayName: '状态',
- width: '6%',
- enableFiltering: false
- },
- // {
- // name: 'executionTime',
- // displayName: '执行时长',
- // width: '10%',
- // enableFiltering: false,
- // cellTemplate: '<div class="ui-grid-cell-contents">{{row.entity.executionTime + "分钟"}}</div>'
- // },
- {
- name: 'executionTime1',
- displayName: '当前批次进度',
- width: '12%',
- enableFiltering: false,
- cellTemplate: `<div class="ui-grid-cell-contents" title="{{row.entity.percent}}%">
- <progressbar value="row.entity.percent" type="success">{{row.entity.percent}}%</progressbar>
- </div>`
- },
- {
- name: 'batchNoDesc',
- displayName: '最新批次号',
- width: '15%',
- enableFiltering: false
- },
- // {
- // name: 'createUser.name',
- // displayName: '创建人',
- // width: '8%',
- // enableFiltering: false
- // },
- // { name: 'createTime', displayName: '创建时间', width: '12%', 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.seeFunction(row.entity)" class="bianjifont">查看</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: {
- inspection: data
- }
- };
- $state.go('app.inspection.editor', {
- formKey: 'inspectionform',
- service: 'api_bpm_data',
- model: JSON.stringify(filedata)
- });
- };
- //跳转到查看列表
- $scope.seeFunction = function (data) {
- var filedata = {
- model: {
- inspection: data
- }
- };
- $state.go('app.inspection.form', {
- formKey: 'inspection__detailform',
- service: 'api_bpm_data',
- model: JSON.stringify(filedata)
- });
- }
- // $scope.onDblClick = function(data) {
- // var filedata = {
- // model: {
- // inspection: data.entity
- // }
- // };
- // $state.go('app.inspection.form', {
- // formKey: 'inspection__detailform',
- // service: 'api_bpm_data',
- // model: JSON.stringify(filedata)
- // });
- // };
- //跳转到查看列表
- $scope.lookFunction = function (data) {
- var filedata = {
- model: {
- inspection: 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.reload = function () {
- // var filterData = JSON.parse(sessionStorage.inspectPlanParameter);
- // var data={
- // "idx":filterData.idx,
- // "sum":filterData.sum
- // }
- // $scope.inspectdata={};
- delete $scope.fileData.inspection.inspectionTypeDTO;
- delete $scope.fileData.inspection.title;
- delete $scope.fileData.inspection.executeUser;
- delete $scope.fileData.inspection.createUser;
- delete $scope.fileData.inspection.status;
- $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 = [];
- api_bpm_data.fetchDataList('inspection', filterData).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;
- }
- // $scope.myData = [];
- api_bpm_data.fetchDataList('inspection', filterData).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,
- "inspection": {
- }
- }
- $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: "inspection_status",
- 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 () {
- api_configure_data.fetchDataList("user", {
- "idx": 0,
- "sum": 1000,
- "user":{
- "simple": true,
- 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;
- }]);
|