2025-06-27 10:04:22 +08:00

253 lines
8.0 KiB
JavaScript

app.controller('DWHSCtrl', ['$scope','$http', 'DWHS', '$uibModal', 'wyOdataNodeService', 'stConfig', function ($scope, $http, DWHS, $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;
// console.log($scope.searchSql+"aaa");
// wyOdataNodeService.getData(pubserver, 'DWHS_DB', $scope.tableState, $scope.searchSql).then(function (data) {
// $scope.displayed = data;
//
//
// //当前页面的ID号数组
// $scope.isShow = false;
// $scope.ids = Enumerable.From($scope.displayed).Select(function (x) { return x.id }).ToArray();
//
//
// $scope.myttt = tableState.count;
//
//
// $scope.$broadcast('checkini');
// //console.log($scope.ids);
// });
$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.items='0'
$scope.add = function (id) {
// console.log(id);
if (id !== '0') {
$scope.items = id
} else {
$scope.items = '0';
}
var modalInstance = $uibModal.open({
animation: true,
backdrop: false, // 不让点击背景关闭系统
templateUrl: 'app/model/modalDWHS_Add.html',
controller: 'modalDWHS_AddCtrl',
size: 'md',
//windowTopClass:'dialog'
resolve: {
items: function () {
return $scope.items;
}
}
});
modalInstance.result.then(
function (nclose) {
$scope.Cha();
},
function (ndismiss) {
$scope.returnData = ndismiss
})
}
/*******************查询的方法************************/
//查询条件
$scope.wherestr={
yjldw:'',
mbjldw:''
}
$scope.Cha = function () {
var tiaojianstr=JSON.stringify($scope.wherestr);
$http({
method: 'GET',
url: Gaddress + '/DWHS/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));
DWHS.delete({ id: data }, function (data1) {
//增加日志20211109
addlog("单位换算管理", "删除数据[" + data + "]")
$scope.Cha();
});
})
}
//重置选择项
$scope.selectList = [];
} else {
alert('请选择你要删除的任务');
}
}
}])
app.controller('modalDWHS_AddCtrl', ['$scope','$http', '$uibModalInstance', 'items', 'DWHS','JLDW', function ($scope, $http, $uibModalInstance, items, DWHS,JLDW) {
$scope.EditData={
yjldw:'',
mbjldw:'',
hsgx:'',
bz:''
}
$scope.Yjldw = [];
$scope.Mbjldw = [];
console.log('id显示',$scope.items)
//如果不是空的话,就是已修改
if (items!=='0'){
console.log('加载数据')
$http({
method: 'GET',
url: Gaddress + '/DWHS/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.save = function () {
if (items == '0') { //是添加的时候
console.log('新增数据',$scope.EditData)
$http({
method: 'GET',
url: Gaddress + '/DWHS/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 + '/DWHS/update',
params: {'strJson':JSON.stringify( $scope.EditData)}
}).then(function successCallback(data){
addlog("单位换算管理", "修改数据[" + JSON.stringify(items) + "]")
$uibModalInstance.close(data);
},function errorCallback(response){
})
}
}
//点击返回
$scope.return = function () {
$uibModalInstance.dismiss("界面直接退出");
}
}])