236 lines
7.9 KiB
JavaScript
236 lines
7.9 KiB
JavaScript
|
|
|
|
app.controller('JLDWCtrl', ['$scope','$http','$timeout', 'JLDW', '$uibModal', 'wyOdataNodeService', 'stConfig', function ($scope, $http, $timeout, JLDW, $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.$broadcast('checkini');
|
|
$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.wherestr={jldw:''};
|
|
|
|
$scope.Cha = function () {
|
|
|
|
var tiaojianstr=JSON.stringify($scope.wherestr);
|
|
$http({
|
|
method: 'GET',
|
|
url: Gaddress + '/JLDW/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.items = '0';
|
|
$scope.add = function (id) {
|
|
if (id != '0') {
|
|
$scope.items = id;
|
|
} else {
|
|
$scope.items = '0';
|
|
}
|
|
var modalInstance = $uibModal.open({
|
|
animation: true,
|
|
backdrop: false, // 不让点击背景关闭系统
|
|
templateUrl: 'app/model/modalJLDW_Add.html',
|
|
controller: 'modalJLDW_AddCtrl',
|
|
size: 'md',
|
|
//windowTopClass:'dialog'
|
|
resolve: {
|
|
items: function () {
|
|
return $scope.items;
|
|
}
|
|
}
|
|
});
|
|
modalInstance.result.then(
|
|
function (nclose) {
|
|
$scope.Cha();
|
|
|
|
},
|
|
function (ndismiss) { $scope.returnData = ndismiss }
|
|
)
|
|
|
|
}
|
|
|
|
//删除的方法
|
|
$scope.delete = function () {
|
|
//console.log(id);
|
|
console.log('selectList',$scope.selectList)
|
|
if ($scope.selectList.length > 0) {
|
|
dLayer.confirm('您确定要删除数据吗?', {
|
|
btn: ['确定','取消'] //按钮
|
|
}, function(){
|
|
console.log('选择的内容',$scope.selectList)
|
|
angular.forEach($scope.selectList, function (data) {
|
|
$http({
|
|
method: 'GET',
|
|
url: Gaddress + '/JLDW/delete?id=' +data,
|
|
// params: {id:$scope.items}
|
|
}).then(function successCallback(mydata){
|
|
console.log('返回单个数据的结果',mydata.data.data)
|
|
$scope.EditData=mydata.data.data;
|
|
dLayer.msg('删除成功', {icon: 1,time: 2000},);
|
|
},function errorCallback(response){
|
|
dLayer.msg('删除出现错误,请检查!', {icon: 1,time: 2000},);
|
|
})
|
|
|
|
})
|
|
//重置选择项
|
|
$timeout(function () { $scope.Cha() }, 1000);
|
|
$scope.selectList = [];
|
|
dLayer.msg('完成!', {icon: 1,time: 2000},);
|
|
}, function(){
|
|
dLayer.msg('删除取消', {icon: 1,time: 2000},);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
//alert('请选择你要删除的任务');
|
|
dLayer.msg('请选择你要删除的任务')
|
|
}
|
|
}
|
|
}])
|
|
|
|
app.controller('modalJLDW_AddCtrl', ['$scope', '$http', '$uibModalInstance','items','JLDW' ,function ($scope, $http, $uibModalInstance,items,JLDW) {
|
|
|
|
|
|
$scope.EditData={
|
|
jldw:'',
|
|
bz:''
|
|
}
|
|
|
|
if (items == 0) {
|
|
$scope.BaoCun = true;
|
|
$scope.XiuGai = false;
|
|
} else {
|
|
$scope.BaoCun = false;
|
|
$scope.XiuGai = true;
|
|
}
|
|
|
|
if (items!=='0'){
|
|
console.log('加载数据')
|
|
$http({
|
|
method: 'GET',
|
|
url: Gaddress + '/JLDW/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') {//是添加操作
|
|
|
|
$http({
|
|
method:'GET',
|
|
url: Gaddress + '/JLDW/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 + '/JLDW/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("界面直接退出");
|
|
}
|
|
|
|
}])
|