389 lines
15 KiB
JavaScript
389 lines
15 KiB
JavaScript
|
|
|
|
//获取当前的主页的信息
|
|
app.factory('mainUrl', function ($location) {
|
|
var dPath = $location.protocol() + "://" + $location.host() + ":" + $location.port() + "/";
|
|
return dPath;
|
|
});
|
|
|
|
//表格的页显示组件
|
|
app.directive('pageSelect', function () {
|
|
return {
|
|
restrict: 'E',
|
|
template: '<input type="text" class="select-page" ng-model="inputPage" ng-change="selectPage(inputPage)">',
|
|
link: function (scope, element, attrs) {
|
|
scope.$watch('currentPage', function (c) {
|
|
//alert('df');
|
|
scope.inputPage = c;
|
|
// console.log(c);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
//表格中的全选组件
|
|
app.directive('stCheckboxAll', function ($rootScope) {
|
|
return {
|
|
strict: 'AE',
|
|
scope: {
|
|
currentIds: '=',
|
|
selectList: '=',
|
|
checkinit: '='
|
|
},
|
|
controller: function ($scope) {
|
|
//console.log('jiazaictrl');
|
|
|
|
|
|
$scope.$on('checkini', function () {
|
|
$scope.isChecked = false;
|
|
})
|
|
|
|
$scope.changeSelect = function () {
|
|
if ($scope.isChecked) {
|
|
console.log('选择我中的!!');
|
|
angular.forEach($scope.currentIds, function (value, key) {
|
|
if (Enumerable.From($scope.selectList).Where(function (x) { return x == value }).Count() == 0) {
|
|
//console.log('增加整体' + value );
|
|
$scope.selectList.push(value);
|
|
console.log($scope.selectList);
|
|
}
|
|
})
|
|
} else {
|
|
console.log('没有选择!!!');
|
|
angular.forEach($scope.currentIds, function (value, key) {
|
|
if (Enumerable.From($scope.selectList).Where(function (x) { return x == value }).Count() > 0) {
|
|
//console.log('减少整体' + value );
|
|
$scope.selectList.splice($scope.selectList.indexOf(value), 1);
|
|
console.log($scope.selectList);
|
|
}
|
|
})
|
|
}
|
|
//console.log($scope.selectList);
|
|
$rootScope.$broadcast('allcheck', $scope.isChecked);
|
|
}
|
|
},
|
|
template: '<input type="checkbox" ng-checked="isChecked" ng-model="isChecked" ng-change="changeSelect()" style="vertical-align:top"/>',
|
|
link: function (scope, ele, attr) {
|
|
//console.log('jiazailink');
|
|
scope.isChecked = false;
|
|
//$(ele).attr('checked', 'unchecked');
|
|
|
|
}
|
|
}
|
|
})
|
|
|
|
//表格中的选择 组件
|
|
app.directive('stCheckbox', function () {
|
|
//var isolateScope = $rootScope.new(); // creates a new isolate copy of $rootScope
|
|
return {
|
|
strict: 'AE',
|
|
scope: {
|
|
isChecked: '@',
|
|
id: '@',
|
|
selectList: '='
|
|
},
|
|
controller: function ($scope, $timeout) {
|
|
//检测选择的checkbox的变化
|
|
$timeout(function () {
|
|
dOn();
|
|
dWatch();
|
|
}, 200);
|
|
|
|
|
|
var dOn = function () {
|
|
$scope.$on('allcheck', function (e, d) {
|
|
//console.log('ggfgfdfgds');
|
|
//console.log(e+'TTGGFF');
|
|
$scope.isChecked = d;
|
|
})
|
|
}
|
|
|
|
|
|
var dWatch = function () {
|
|
$scope.$watch('isChecked', function (N, O, scope) {
|
|
//console.log(scope);
|
|
|
|
//以下是组件变化有值的情况
|
|
if (scope.isChecked && scope.id) { //如果是选中的话,查询条数就要变成判断有就不增加
|
|
if (Enumerable.From($scope.selectList).Where(function (x) { return x == scope.id }).Count() == 0) {
|
|
//console.log('增加' + scope.id +N);
|
|
$scope.selectList.push(scope.id);
|
|
}
|
|
} else
|
|
if (N) { //如果取消选中的话,查询有的话就要删除
|
|
if (Enumerable.From($scope.selectList).Where(function (x) { return x == scope.id }).Count() > 0) {
|
|
//console.log('减少' + scope.id + N);
|
|
$scope.selectList.splice(selectList.indexOf(scope.id), 1);
|
|
}
|
|
}
|
|
//console.log($scope.selectList);
|
|
|
|
});
|
|
}
|
|
},
|
|
template: '<input type="checkbox" ng-checked="isChecked" ng-model="isChecked" id="{{id}}" style="vertical-align:top"/>',
|
|
link: function (scope, element, attrs) {
|
|
|
|
if (Enumerable.From(scope.selectList).Where(function (x) { return x == attrs.id }).Count() > 0) {
|
|
scope.isChecked = true;
|
|
}
|
|
|
|
scope.$on('allcheck', function (e, d) {
|
|
console.log('全选择啦!!!');
|
|
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
|
|
|
|
|
|
//jiyunode的数据服务
|
|
//表格的通用服务.
|
|
app.service('wyOdataNodeService', function ($http, $q, stConfig) {
|
|
|
|
//按照传递过来的表格参数返回数据
|
|
this.getData = function (odataUrl, odataTable, tableState, searchFilter) {
|
|
console.log(angular.toJson(tableState));
|
|
var dSql = odataUrl + odataTable + '?$count=true';
|
|
//如果排序有值
|
|
if (tableState.sort.predicate) {
|
|
dSql = dSql + "&$orderby=" + tableState.sort.predicate + " " + (tableState.sort.reverse ? 'desc' : 'asc');
|
|
}
|
|
//如果查询有值
|
|
if (tableState.search) {
|
|
angular.forEach(tableState.search.predicateObject, function (value, key) {
|
|
//console.log("测试值:" + angular.isNumber(value) + key + '||' + value);
|
|
dSql = dSql + "&$filter=startswith(" + key + ",'" + value + "')";
|
|
});
|
|
}
|
|
|
|
//通过数组传进来的查询参数进行拼起来并且进行查询
|
|
if (searchFilter != '') {
|
|
// dSql = dSql + "&$filter=" + searchFilter.join(' and ');
|
|
dSql = dSql + "&$filter=" + searchFilter;
|
|
}
|
|
|
|
//一定加上分页
|
|
dSql = dSql + "&$skip=" + tableState.pagination.start + "&$top=" + tableState.pagination.number;
|
|
console.log(dSql);
|
|
|
|
var deferred = $q.defer();
|
|
|
|
var tableLength = 0;
|
|
$http.get(dSql, {}).success(function (data) {
|
|
// console.log(angular.toJson(data));
|
|
// alert(angular.toJson(Enumerable.From(data).ToArray()[0].Value));
|
|
|
|
var displayed = data.value;
|
|
var dPageCount = Math.ceil(Enumerable.From(data).ToArray()[0].Value / tableState.pagination.number);
|
|
|
|
//总长度
|
|
tableLength = Enumerable.From(data).ToArray()[0].Value;
|
|
|
|
tableState.count = tableLength;
|
|
tableState.pagination.numberOfPages = dPageCount;
|
|
deferred.resolve(displayed);
|
|
|
|
//
|
|
});
|
|
|
|
// console.log(angular.toJson(deferred.promise));
|
|
// deferred.promise.tableLength = tableLength;
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
|
|
}
|
|
|
|
//按照传递过来的表格参数返回数据
|
|
this.getData2 = function (odataUrl, odataTable, tableState, searchFilter) {
|
|
console.log(angular.toJson(tableState));
|
|
var dSql = odataUrl + odataTable + '?$count=true';
|
|
var mysqlstr1 = odataUrl + odataTable + '?$count=true';
|
|
//如果排序有值
|
|
if (tableState.sort.predicate) {
|
|
dSql = dSql + "&$orderby=" + tableState.sort.predicate + " " + (tableState.sort.reverse ? 'desc' : 'asc');
|
|
}
|
|
//如果查询有值
|
|
if (tableState.search) {
|
|
angular.forEach(tableState.search.predicateObject, function (value, key) {
|
|
//console.log("测试值:" + angular.isNumber(value) + key + '||' + value);
|
|
dSql = dSql + "&$filter=startswith(" + key + ",'" + value + "')";
|
|
mysqlstr1 = mysqlstr1 + "&$filter=startswith(" + key + ",'" + value + "')";
|
|
});
|
|
}
|
|
|
|
//通过数组传进来的查询参数进行拼起来并且进行查询
|
|
if (searchFilter != '') {
|
|
// dSql = dSql + "&$filter=" + searchFilter.join(' and ');
|
|
dSql = dSql + "&$filter=" + searchFilter;
|
|
mysqlstr1 = mysqlstr1 + "&$filter=" + searchFilter;
|
|
}
|
|
|
|
|
|
//一定加上分页
|
|
dSql = dSql + "&$skip=" + tableState.pagination.start + "&$top=" + tableState.pagination.number;
|
|
console.log(dSql);
|
|
|
|
var deferred = $q.defer();
|
|
var tableLength = 0;
|
|
$http.get(dSql, {}).success(function (data) {
|
|
// console.log(angular.toJson(data));
|
|
// alert(angular.toJson(Enumerable.From(data).ToArray()[0].Value));
|
|
var jcxxxheji = "计算中...";
|
|
var displayed = data.value;
|
|
var dPageCount = Math.ceil(Enumerable.From(data).ToArray()[0].Value / tableState.pagination.number);
|
|
//总长度
|
|
tableLength = Enumerable.From(data).ToArray()[0].Value;
|
|
tableState.count = tableLength;
|
|
tableState.jcxxxheji = jcxxxheji;
|
|
tableState.pagination.numberOfPages = dPageCount;
|
|
tableState.mysqlstr11 = mysqlstr1;
|
|
deferred.resolve(displayed);
|
|
});
|
|
|
|
// console.log(angular.toJson(deferred.promise));
|
|
// deferred.promise.tableLength = tableLength;
|
|
return deferred.promise;
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
//达梦的新的服务20231015Add
|
|
app.service('wyDMService', function ($http, $q, stConfig) {
|
|
|
|
//按照传递过来的表格参数返回数据
|
|
this.getData = function (dataUrl, whereStr, tableState, searchFilter) {
|
|
console.log(angular.toJson(tableState));
|
|
//var dSql = odataUrl + odataTable + '?$count=true';
|
|
var dSql=dataUrl + "?wherestr=" + JSON.stringify( whereStr);
|
|
//如果排序有值
|
|
// if (tableState.sort.predicate) {
|
|
// dSql = dSql + "&$orderby=" + tableState.sort.predicate + " " + (tableState.sort.reverse ? 'desc' : 'asc');
|
|
// }
|
|
//如果查询有值
|
|
// if (tableState.search) {
|
|
//
|
|
// debugger
|
|
// angular.forEach(tableState.search.predicateObject, function (value, key) {
|
|
// //console.log("测试值:" + angular.isNumber(value) + key + '||' + value);
|
|
// dSql = dSql + "&$filter=startswith(" + key + ",'" + value + "')";
|
|
// });
|
|
// }
|
|
|
|
//通过数组传进来的查询参数进行拼起来并且进行查询
|
|
// if (searchFilter != '') {
|
|
// // dSql = dSql + "&$filter=" + searchFilter.join(' and ');
|
|
// dSql = dSql + "&$filter=" + searchFilter;
|
|
// }
|
|
|
|
//一定加上分页
|
|
dSql = dSql + "¤t=" + tableState.pagination.start + "&size=" + tableState.pagination.number;
|
|
console.log('语句',dSql);
|
|
var deferred = $q.defer();
|
|
|
|
var tableLength = 0;
|
|
$http.get(dSql, {}).success(function (data) {
|
|
console.log(angular.toJson(data));
|
|
// alert(angular.toJson(Enumerable.From(data).ToArray()[0].Value));
|
|
debugger
|
|
var displayed = data.value;
|
|
var dPageCount = Math.ceil(Enumerable.From(data).ToArray()[0].Value / tableState.pagination.number);
|
|
|
|
//总长度
|
|
tableLength = Enumerable.From(data).ToArray()[0].Value;
|
|
|
|
tableState.count = tableLength;
|
|
tableState.pagination.numberOfPages = dPageCount;
|
|
deferred.resolve(displayed);
|
|
|
|
//
|
|
});
|
|
|
|
// console.log(angular.toJson(deferred.promise));
|
|
// deferred.promise.tableLength = tableLength;
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
|
|
}
|
|
|
|
//按照传递过来的表格参数返回数据
|
|
this.getData2 = function (odataUrl, odataTable, tableState, searchFilter) {
|
|
console.log(angular.toJson(tableState));
|
|
var dSql = odataUrl + odataTable + '?$count=true';
|
|
var mysqlstr1 = odataUrl + odataTable + '?$count=true';
|
|
//如果排序有值
|
|
if (tableState.sort.predicate) {
|
|
dSql = dSql + "&$orderby=" + tableState.sort.predicate + " " + (tableState.sort.reverse ? 'desc' : 'asc');
|
|
}
|
|
//如果查询有值
|
|
if (tableState.search) {
|
|
angular.forEach(tableState.search.predicateObject, function (value, key) {
|
|
//console.log("测试值:" + angular.isNumber(value) + key + '||' + value);
|
|
dSql = dSql + "&$filter=startswith(" + key + ",'" + value + "')";
|
|
mysqlstr1 = mysqlstr1 + "&$filter=startswith(" + key + ",'" + value + "')";
|
|
});
|
|
}
|
|
|
|
//通过数组传进来的查询参数进行拼起来并且进行查询
|
|
if (searchFilter != '') {
|
|
// dSql = dSql + "&$filter=" + searchFilter.join(' and ');
|
|
dSql = dSql + "&$filter=" + searchFilter;
|
|
mysqlstr1 = mysqlstr1 + "&$filter=" + searchFilter;
|
|
}
|
|
|
|
|
|
//一定加上分页
|
|
dSql = dSql + "&$skip=" + tableState.pagination.start + "&$top=" + tableState.pagination.number;
|
|
console.log(dSql);
|
|
|
|
var deferred = $q.defer();
|
|
var tableLength = 0;
|
|
$http.get(dSql, {}).success(function (data) {
|
|
// console.log(angular.toJson(data));
|
|
// alert(angular.toJson(Enumerable.From(data).ToArray()[0].Value));
|
|
var jcxxxheji = "计算中...";
|
|
var displayed = data.value;
|
|
var dPageCount = Math.ceil(Enumerable.From(data).ToArray()[0].Value / tableState.pagination.number);
|
|
//总长度
|
|
tableLength = Enumerable.From(data).ToArray()[0].Value;
|
|
tableState.count = tableLength;
|
|
tableState.jcxxxheji = jcxxxheji;
|
|
tableState.pagination.numberOfPages = dPageCount;
|
|
tableState.mysqlstr11 = mysqlstr1;
|
|
deferred.resolve(displayed);
|
|
});
|
|
|
|
// console.log(angular.toJson(deferred.promise));
|
|
// deferred.promise.tableLength = tableLength;
|
|
return deferred.promise;
|
|
}
|
|
|
|
})
|
|
|
|
|
|
app.directive('stLoading', function () {
|
|
return {
|
|
strict: 'AE',
|
|
scope: {
|
|
isShow: '=',
|
|
tipShow: '@'
|
|
},
|
|
controller: function ($scope) {
|
|
//$scope.isLoading = $scope.isShow;
|
|
if ($scope.tipShow == "") {
|
|
$scope.tipShow = "正在加载中......";
|
|
}
|
|
},
|
|
template: '<tbody style="width:100%"><tr><td colspan="120" style="text-align:center;"><div ng-if="isShow" style="font-size:16">{{tipShow}}<img src="./img/1.gif" style="width:40%;height:40%;" /></div></td></tr></tbody>'
|
|
}
|
|
|
|
})
|