app.controller('JZJGCtrl', ['$scope', '$http', 'JCDW', '$uibModal', 'wyOdataNodeService', 'stConfig', function ($scope, $http, JCDW, $uibModal, wyOdataNodeService, stConfig) { /**************************************************************************************/ //通过STMATETable 分页显示数据 //以下的参数每个控制器都要有一份 $scope.tableState = []; //这个参数后面会让每次访问服务器后进行同步返回的值赋值,作为中间值使用 $scope.selectList = []; //这个参数会让每次选中或者没有选中的条目直接暴露在这个值里面 $scope.searchSql = ''; //这个参数是自己组合相关的复杂查询条件 $scope.isShow = false; //这个参数主要进行页面加载的loading显示的directive的值得操作 $scope.itemsOptions = [5, 10, 20, 50, 100, 200]; //这个参数进行分页页面上面的每页多少条的设置 $scope.curpageNumber = 10; //这个参数传递当前的每页多少条的数据 //任何动作都会触发服务端的接口 $scope.getService = function (tableState, ctrl) { $scope.tableState = tableState; if (!$scope.tableState.pagination.number) { $scope.tableState.pagination.number = $scope.curpageNumber; } $scope.isShow = true; $scope.Cha(); }; //模板的分页选择触发操作 $scope.setPageNumber = function (pageNo) { // alert("1") $scope.getService($scope.tableState); } //查询参数的调用 $scope.search = function () { $scope.searchSql = [$scope.sql]; $scope.getA($scope.tableState); //约定成数字的按照前后 //日期按照前后 //字符串的模糊查询 //var sql = '$filter=EventDateTime eq DateTime'2010-12-21T10:10:19.390625'; //日期参考如下: //(EventDateTime eq DateTime'2010-12-21T10:10:19.390625' ) and (BusinessUnitCode eq '2') //var dT=dd ge 12 and dd le 33 } /***************************************************************************************/ $scope.Myjson = [ { name: "机构编号", PY: "JGBH" }, { name: "检测机构名称", PY: "JCJGMC" } ] /**************************查看/修改/添加 详细信息**************************/ $scope.items = 0; $scope.open = function (ID) { if (ID != 0) { $scope.items = ID; } else ( $scope.items = '0' ) //console.log($scope.items); var modalInstance = $uibModal.open({ animation: true, backdrop: false, // 不让点击背景关闭系统 templateUrl: 'app/model/modalJZJG.html', controller: 'modalJZJGCtrl', size: 'md', //windowTopClass:'dialog' resolve: { items: function () { return $scope.items; } } }); modalInstance.result.then( function (nclose) { $scope.Cha(); }, function (ndismiss) { $scope.returnData = ndismiss } ) } /*********************查询数据************************/ $scope.Cha = function () { var tiaojianstr=JSON.stringify($scope.wherestr); $http({ method: 'GET', url: Gaddress + '/JCDW/getlist', params:{ tiaojianstr:tiaojianstr, pagenumber: parseInt($scope.tableState.pagination.start/$scope.tableState.pagination.number)+1, pagesize:$scope.tableState.pagination.number } }).then(function successCallback(mydata){ $scope.displayed = angular.fromJson(mydata.data.data); $scope.zongTiaoShu = mydata.data.length; $scope.isShow = false; //当前页面的ID号数组 $scope.ids = Enumerable.From($scope.displayed).Select(function (x) { return x._id }).ToArray(); //表格数量 $scope.myttt = mydata.data.length; $scope.tableState.count = mydata.data.length; $scope.tableState.pagination.numberOfPages = Math.ceil(mydata.data.length / $scope.curpageNumber); $scope.inputPage = $scope.tableState.pagination.numberOfPages; $scope.tableState = $scope.tableState; },function errorCallback(response){ }) //增加日志20211109 addlog("检测机构", "查询[" + $scope.searchSql + "]") //$scope.getService($scope.tableState, $scope.searchSql); } /*************************删除数据********************************/ $scope.delete = function () { if ($scope.selectList.length > 0) { if (confirm("确定要删除任务?")) { angular.forEach($scope.selectList, function (data) { // console.log(angular.toJson(data)); JCDW.delete({ID: data}, function (data1) { $scope.Cha(); }); }) } //重置选择项 $scope.selectList = []; } else { alert('请选择你要删除的任务'); } } }]) app.controller('modalJZJGCtrl', ['$scope','$http', '$uibModalInstance', 'items', 'JCDW', function ($scope, $http, $uibModalInstance, items, JCDW) { $scope.EditData={ JCJGMC: '', JGBH: '' } if (items!=='0'){ console.log('加载数据') $http({ method: 'GET', url: Gaddress + '/JCDW/getdata?id=' +items, // params: {id:$scope.items} }).then(function successCallback(mydata){ console.log('返回单个数据的结果',mydata.data.data) $scope.EditData=mydata.data.data; },function errorCallback(response){ }) } //确认 保存数据 $scope.Ok = function () { if (items == '0') { $http({ method: 'GET', url: Gaddress + '/JCDW/add', params: {'strJson':JSON.stringify( $scope.EditData)} }).then(function successCallback(mydata){ addlog("检测机构", "新增数据" + JSON.stringify($scope.EditData)) $uibModalInstance.close($scope.EditData); },function errorCallback(response){ }) } else { $http({ method: 'GET', url: Gaddress + '/JCDW/update', params: {'strJson':JSON.stringify( $scope.EditData)} }).then(function successCallback(data){ addlog("检测机构", "修改数据[" + JSON.stringify(items) + "]") $uibModalInstance.close(data); },function errorCallback(response){ }) } } $scope.Cancel = function () { $uibModalInstance.dismiss("界面直接退出"); } } ])