网络请求增批删改模糊查

<!DOCTYPE html>
<html ng-app="MyApp">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.input{
border-radius: 20px;
border: 1 solid black;
height: 30px;
}
#remove1{
border-radius:10px;
width: 100px;
height: 40px;
background-color: white;
}

#tab1{
margin-top: 50px;
}

#tab2{
margin-top: 10px;
}

#tab2 tr:nth-child(even){
background-color: #EEEEEE;
}

#but{
border-radius: 10px;
border-color: black;
}
</style>
<script src="../libs/angular.min.js"></script>
<script src="../libs/angular-route.min.js"></script>
<script>
var app = angular.module("MyApp",[]);
app.controller("Mycon",function($scope,$http){
$http({
method:"GET",
url:"http://result.eolinker.com/TucCTQueffdc1d1aaa3be05d8c62e9bb5d3e8b495f97cca?uri=hybrid"
}).success(function(data){
//执行请求成功的代码
$scope.datas = data;
console.log(data);
}).error(function(){
//执行请求失败的代码
})
$scope.date1 = new Date().getTime();
$scope.ff = true;
$scope.gg = false;
//全选/反选多选框的点击事件
$scope.cb = function(){

if($scope.ck){//判断当点击全选框时
for(var i=0;i<$scope.datas.length;i++){
if($scope.datas[i].state){//当其他复选框为选中状态时
$scope.datas[i].state = false;//改为不选中状态
}else{//当其他复选框为不选中状态时
$scope.datas[i].state = true;//改为选中状态
}
}

}else{//判断当不点击全选框时
for(var i=0;i<$scope.datas.length;i++){
if($scope.datas[i].state){//当其他复选框为选中状态时
$scope.datas[i].state = false;//改为不选中状态
}else{//当其他复选框为不选中状态时
$scope.datas[i].state = true;//改为选中状态
}
}
}

}

//批量删除的点击事件
$scope.Pxremove = function(){
$scope.arr = [];

for(var i=0;i<$scope.datas.length;i++){
if($scope.datas[i].state){
$scope.arr.push($scope.datas[i].name);
}
}
if($scope.arr.length<=0){
alert("请选择一条数据哦");
}else{
for(var j=0 ;j<$scope.arr.length;j++){
for(var i=0;i<$scope.datas.length;i++){
   if($scope.arr[j]==$scope.datas[i].name){
    $scope.datas.splice(i,1);
    if($scope.datas.length<=0){//判断当数据为0时
    $scope.ff = false;//把菜单功能框隐藏
    $scope.gg = true;//把无数据操作提示展示
    }
   }
}
}
}
}



//点击删除的事件
$scope.remove = function(index){
if(confirm("是否要删除数据")){//提示弹出框提示,点击确认删除,点击取消不删除
$scope.datas.splice(index,1);

if($scope.datas.length<=0){//判断当数据为0时
$scope.ff = false;//把菜单功能框隐藏
$scope.gg = true;//把无数据操作提示展示
}
alert("删除成功");//提示
}

}
//排序
$scope.op = "根据出生日期排序";
$scope.sel = function(){
if($scope.op=="根据出生日期排序"){//判断下拉框选中根据出生日期排序
$scope.datas.sort(function(a,b){
return a.birthday-b.birthday;
});
}
if($scope.op=="根据薪资排序"){//判断下拉框选中根据薪资排序
$scope.datas.sort(function(a,b){
return a.salary-b.salary;
});
}
}
});
</script>


</head>
<body ng-controller="Mycon">
<!--默认不展示-->
<center ng-show="gg" style="margin-top: 200px;">
<h1>无数据操作</h1>
</center>
<!--默认展示-->
<center ng-show="ff">
<table id="tab1" border="0" cellpadding="6" cellspacing="1">
<tr>
<td><input class="input" id="input1" type="text" placeholder="根据姓名模糊查询..." ng-model="name"/></td>
<td><input class="input" id="input2" type="text" placeholder="根据部门模糊查询..." ng-model="department"/></td>
<td>
<select style="height: 30px;" ng-change="sel()" ng-model="op">
<option>根据出生日期排序</option>
<option>根据薪资排序</option>
</select>
</td>
<td><button id="remove1" ng-click="Pxremove()">批量删除</button></td>
</tr>
</table>
<table id="tab2" border="1" cellpadding="6" cellspacing="0">
<tr style="background-color: #999999;">
<td><input type="checkbox" ng-click="cb()" ng-model="ck" /></td>
<td>员工姓名</td>
<td>员工年龄</td>
<td>员工性别</td>
<td>员工薪资</td>
<td>出生日期</td>
<td>部门名称</td>
<td>删除</td>
</tr>
<tr ng-repeat="x in datas | filter : {name:name} | filter : department">
<td><input type="checkbox" ng-model="x.state" /></td>
<td>{{x.name}}</td>
<td>{{(date1 | date:'yyyy')-(x.birthday | date:'yyyy')}}</td>
<td>{{x.gender}}</td>
<td>{{x.salary | currency:'¥'}}</td>
<td>{{x.birthday | date:'yyyy-MM-dd HH:mm:ss'}}</td><!--把出生日期使用过滤器,变成 年月日时分秒格式-->
<td>{{x.department.name}}</td>
<td><button id="but" ng-click="remove($index)">删除</button></td>
</tr>
</table>
</center>
</body>


</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于使用Ajax和MyBatis进行增删改模糊询和分页的操作,你可以按照以下步骤进行: 1. 建立后端接口:首先,在你的后端框架(如Spring MVC)中,建立相应的Controller来处理前端发送的请求。在Controller中,你可以使用MyBatis来执行数据库操作。 2. Ajax请求发送:在前端页面中,使用Ajax技术发送请求到后端接口。你可以使用jQuery或其他JavaScript库来方便地发送Ajax请求。 3. 前端页面设计:设计一个用户界面,包含相应的表单或搜索框,用于输入询条件或操作数据。 4. 后端接口处理:在后端Controller中,根据接收到的请求参数,调用对应的MyBatis方法来执行数据库操作。例如,你可以使用`@RequestMapping`注解来映射不同的请求路径,并在方法中调用MyBatis的Mapper接口方法。 5. MyBatis配置:在MyBatis的配置文件中,配置数据库连接信息和相应的Mapper映射文件。在Mapper映射文件中定义增删改的SQL语句,并与对应的Java方法进行映射。 6. 分页处理:如果需要进行分页询,你可以在后端接口中添加分页参数,并在MyBatis的Mapper映射文件中使用相应的SQL语句进行分页询。可以通过`LIMIT`关键字或者使用MyBatis提供的插件来实现分页功能。 需要注意的是,以上步骤只是一个简单的指导,具体的实现方式会根据你的项目环境和需求有所不同。你需要根据自己的项目进行适当的调整和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值