123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- "use strict";
- /**
- * controller for User Profile Example
- */
- app.controller("inspectReportCtrl", [
- "$rootScope",
- "$scope",
- "$state",
- "$timeout",
- "$interval",
- "$modal",
- "SweetAlert",
- "i18nService",
- "uiGridConstants",
- "uiGridGroupingConstants",
- "Restangular",
- "api_bpm_schedule",
- "api_bpm_data",
- "api_bpm",
- "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_bpm,
- 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
- // }
- // }
- // 打印
- $scope.print = function () {
- console.log(Print);
- Print("#print", {
- padding:'5 5',
- afterprint: () => {},
- cancel: () => {},
- });
- // 保证打印正好铺满A4高度
- let A4height = 297; // A4高度297mm
- let ctxpage = document.querySelectorAll(".fm");
- ctxpage.forEach((i, k) => {
- let eachpage_mm = px2mm(i.clientHeight); // 单位px转mm
- console.log(k + "页高度px:", i.clientHeight, "高度mm:", eachpage_mm);
- //高度大于A4,则按比例缩小打印区域
- if (eachpage_mm > A4height) {
- let zoom = A4height / eachpage_mm;
- console.log(k + "页zoom:", zoom);
- i.style.zoom = zoom;
- }
- });
- };
- //获取计划主题和批次号,级联
- $scope.titles = [];
- $scope.batchNos = [];
- $scope.isMask = true;
- $scope.queryList = { title: "", batchNo: "" };
- $scope.getInfo = function () {
- var postData = {
- idx: 0,
- sum: 9999,
- inspection: {},
- };
- api_bpm.fetchDataList("inspection", postData).then(function (result) {
- if (result.status == 200) {
- $scope.titles = result.list.map((v) => ({
- id: v.id,
- title: v.title,
- batchNos: v.batchNos,
- }));
- $scope.batchNos = [];
- }
- });
- };
- $scope.getInfo();
- //选择计划主题
- $scope.changeTitle = function () {
- console.log($scope.queryList.title);
- $scope.queryList.batchNo = "";
- if ($scope.queryList.title.batchNos) {
- $scope.batchNos = $scope.queryList.title.batchNos.map((v) => ({
- id: v,
- name: v,
- }));
- }
- };
- //选择计划主题和批次号,确定
- $scope.onClick = function () {
- if (!$scope.queryList.title || !$scope.queryList.batchNo) {
- SweetAlert.swal({
- title: "数据为空",
- text: "请填写必选项",
- type: "warning",
- });
- return;
- }
- $scope.isMask = false;
- console.log($scope.queryList)
- $scope.fileData = {
- idx: 0,
- sum: 10,
- batchNo: $scope.queryList.batchNo.name,
- inspectionId: $scope.queryList.title.id
- };
- $scope.refreshData("expand-right", $scope.fileData);
- };
- // ------------------------------------------------------------------
- var defaultFilterData = {
- idx: 0,
- sum: 10,
- };
- var inspectPlanParameter = {
- idx: 0,
- sum: 10,
- operation: "",
- status: "",
- inspection: {
- inspectionTypeDTO: {
- id: "",
- },
- },
- };
- //本地存储
- sessionStorage.inspectPlanParameter = JSON.stringify(inspectPlanParameter);
- $scope.gridOptions = {};
- $scope.gridOptions.data = "myData";
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableRowHeaderSelection = false;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.rowHeight = 252;
- $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.columnDefs = [
- {
- name: "item",
- displayName: "序号",
- width: 50,
- enableFiltering: false,
- },
- {
- name: "startTime",
- displayName: "日期",
- width: 168,
- enableFiltering: true,
- cellTemplate:
- '<div class="ui-grid-cell-contents">{{row.entity.startTime | date:"yyyy-MM-dd HH:mm:ss"}}</div>',
- },
- {
- name: "type",
- displayName: "巡检范围",
- width: "17%",
- enableFiltering: false,
- },
- {
- name: "inspectItem",
- displayName: "巡检项",
- width: "25%",
- enableFiltering: false,
- cellTemplate: `<div class="ui-grid-cell-contents">
- <div class="inspectPar">
- <p ng-repeat="item in row.entity.xj_items">
- <span ng-if="item.key == 'sdCheckEnable7'||item.key == 'sdCheckEnable11'||item.key == 'sdCheckEnable12'">{{item.name}}:{{item.value=="true"?"是":"否"}}</span>
- <span ng-if="item.key != 'sdCheckEnable7'&&item.key != 'sdCheckEnable11'&&item.key != 'sdCheckEnable12'">{{item.name}}:{{item.value=="true"?"正常":"异常"}}</span>
- </p>
- </div>
- </div>`,
- },
- {
- name: "pic",
- displayName: "巡检图片",
- width: "18%",
- enableFiltering: false,
- cellTemplate:
- '<div class="ui-grid-cell-contents"><img class="xj_img" ng-click="grid.appScope.seePic(row.entity,imageurl)" ng-repeat="(index,imageurl) in row.entity.filePath" ng-src="{{imageurl}}"/></div>',
- },
- // {
- // name: "pic1",
- // displayName: "巡检图片",
- // width: "18%",
- // enableFiltering: false,
- // cellTemplate:
- // '<div class="ui-grid-cell-contents"><img class="xj_img" ng-click="grid.appScope.seePic(row.entity,index)" ng-repeat="(item,index) in [1,2,3]" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp2.itc.cn%2Fq_70%2Fimages03%2F20201101%2F75417504ddc843d78610d1cb8dd9c402.jpeg&refer=http%3A%2F%2Fp2.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1649583898&t=1ead2b8808f10e3da9d6864543d90bce"/></div>',
- // },
- {
- name: "model.descriptionTextarea",
- displayName: "整改意见",
- width: "18%",
- enableFiltering: false,
- cellTemplate:
- '<div class="ui-grid-cell-contents"><div class="inspectPar"><p>{{row.entity.model.descriptionTextarea}}</p></div></div>',
- },
- {
- name: "userName",
- displayName: "巡检人",
- width: "12%",
- enableFiltering: false,
- },
- {
- name: "address",
- 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.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)" 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>",
- // },
- ];
- $scope.selected = {
- items: [],
- };
- $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);
- // }
- // );
- //跳转到查看列表
- $scope.seePic = function (data, imageurl) {
- console.log(data, imageurl);
- var i = imageurl.lastIndexOf("/");
- var title = imageurl.slice(i + 1).split(".")[0];
- $modal.open({
- backdrop: false,
- templateUrl: "assets/views/customform/tpl/ui-showimage.html",
- controller: function ($scope, scope, $modalInstance) {
- $scope.title = title;
- $scope.imageurl = imageurl;
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- },
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- });
- };
- //勾选行事件
- 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.refreshData = function (style, filterData) {
- $scope.ldloading[style.replace("-", "_")] = true;
- if (angular.isUndefined(filterData)) {
- filterData = defaultFilterData;
- }
- $scope.myData = [];
- api_bpm.report(filterData).then(
- function (data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions.totalItems = myData.totalNum;
- if (angular.isArray(myData.data)) {
- $scope.myData = myData.data;
- for (var i = 0; i < $scope.myData.length; i++) {
- $scope.myData[i]["item"] =
- i + 1 + filterData.idx * filterData.sum;
- }
- for (var i = 0; i < $scope.myData.length; i++) {
- //处理日期
- $scope.myData[i].startTime = new Date($scope.myData[i].startTime);
- // 处理图片
- if ($scope.myData[i].filePath) {
- $scope.myData[i].filePath = $scope.myData[i].filePath
- .split(",")
- .map((v) => imgBaseUrl + "/file" + v);
- } else {
- $scope.myData[i].filePath = [];
- }
- //巡检项cnm
- $scope.myData[i].xj_items = $scope.myData[i].fields
- .filter((v) => {
- v.key = (v.key || "").toString();
- return v.key.indexOf("sdCheckEnable") > -1;
- })
- .map((v) => ({
- key: v.key,
- name: v.templateOptions.label,
- value: $scope.myData[i].model[v.key],
- }));
- }
- console.log($scope.myData);
- } 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.report(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;
- }
- 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";
- }
- }
- } else {
- SweetAlert.swal({
- title: "数据为空",
- text: myData.data,
- type: "warning",
- });
- }
- $scope.ldloading[style.replace("-", "_")] = false;
- },
- function () {
- $scope.ldloading[style.replace("-", "_")] = false;
- }
- );
- };
- $scope.ldloading = {};
- // $scope.fileData = {
- // idx: 0,
- // sum: 10,
- // inspection: {},
- // };
- // $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);
- // });
- },
- ]);
|