javaWeb上移下移(SpringMVC+Mabits+MySql)
文章已移至:https://blog.csdn.net/baidu_35468322/article/details/79643356
移动之前:

移动之后:

1、控制层
/**
* 修改排序
*
* @param out
* @author wangsai
*/
@RequestMapping(value = "/upDownMove")
public void updESort(PrintWriter out){
PageData pd=this.getPageData();
try {
pd.put("EDIT_TIME", Tools.date2Str(new Date()));
exampleQuestionService.upDownMove(pd);
out.print("success");
} catch (Exception e) {
e.printStackTrace();
}
out.flush();
}
2、XML
<!-- 上移下移 -->
<update id="upDownMove" parameterType="pd">
update
<include refid="examQuesTableName"></include>
set
E_SORT = (
select
e.E_SORT
from (
select
E_SORT
from
<include refid="examQuesTableName"></include>
where
ID = #{ID}
and
EXAMPLE_ID = #{EXAMPLE_ID}
and
ACTIVE_FALG = '0'
) e
),
EDIT_TIME = #{EDIT_TIME}
where
ID = (
select
i.ID
from (
select
ID
from
<include refid="examQuesTableName"></include>
where
E_SORT = #{E_SORT}
and
EXAMPLE_ID = #{EXAMPLE_ID}
and
ACTIVE_FALG = '0'
) i
)
and
EXAMPLE_ID = #{EXAMPLE_ID}
and
ACTIVE_FALG = '0';<!-- 正常情况下这句话是没用的 --> update
<include refid="examQuesTableName"></include>
set
E_SORT = #{E_SORT},
EDIT_TIME = #{EDIT_TIME}
where
ID = #{ID}
and
ACTIVE_FALG = '0';<!-- 正常情况下这句话是没用的 -->
</update>
3、html
<table class="content_main_table">
<thead>
<tr>
<th style="width:50px;">序号</th>
<th>问题</th>
<th style="width: 160px;">移动</th>
<th style="width: 160px;">操作</th>
</tr>
</thead>
<tbody>
<!-- 开始循环 -->
<c:choose>
<c:when test="${not empty examQuesList}">
<c:if test="${QX.cha == 1 }">
<c:forEach items="${examQuesList}" var="ques" varStatus="i">
<tr class="courseList">
<td>${i.index+1}</td>
<td>
<p style="line-height: 30px; color: #000; font-size: 14px;">
${ques.CONTENT}
</p>
</td>
<td>
<c:choose>
<c:when test="${QX.edit != 1}">
无权限
</c:when>
<c:otherwise>
<c:if test="${QX.edit == 1 }">
<a class="saveBtn ${i.index+1 == 1 ? 'canNotClick' : ''}" title="上移" onclick="moveUp(this,'${i.index+1}','${ques.ID}')"><i class='icon-arrow-up'></i></a>
<a class="whiteBtn ${i.index+1 == fn:length(examQuesList) ? 'canNotClick' : ''}" title="下移" onclick="moveDown(this,'${i.index+1}','${ques.ID}')"><i class='icon-arrow-down'></i></a>
</c:if>
</c:otherwise>
</c:choose>
</td>
<td>
<c:choose>
<c:when test="${(QX.edit != 1 && QX.del != 1)}">
无权限
</c:when>
<c:otherwise>
<c:if test="${QX.edit == 1 }">
<a class="a_blue" title="编辑" onclick="edit('${ques.ID}')"><i class='icon-edit'></i></a>
</c:if>
<c:if test="${QX.del == 1 }">
<a class="delBtn" onclick="del('${ques.ID}');" title="删除"><i class='icon-trash'></i></a>
</c:if>
</c:otherwise>
</c:choose>
</td>
</tr>
</c:forEach>
</c:if>
<c:if test="${QX.cha == 0 }">
<tr>
<td colspan="4">您无权查看</td>
</tr>
</c:if>
</c:when>
<c:otherwise>
<tr class="main_info">
<td colspan="4">没有相关数据</td>
</tr>
</c:otherwise>
</c:choose>
</tbody>
</table>
4、js
//当前页
var currentPage = "${page.currentPage}";
//每页显示的记录
var showCount = "${page.showCount}"; //上移
function moveUp(obj,index,id) {
if(index == 1){
layer.msg("上移到顶了");
return;
}
var self = $(obj);
var _old = self.closest("tr.courseList");
var _new = self.closest("tr.courseList").prev("tr");
if (_new.length > 0) {
var _temp = _old.html();
_old.empty().append(_new.html());
_new.empty().append(_temp);
}
var eSort = (currentPage-1)*showCount+parseInt(index)-1;
$.post("exampleQuestion/upDownMove.do",{E_SORT:eSort,ID:id,EXAMPLE_ID:"${pd.EXAMPLE_ID}"},function(data){
if(data != 'success'){
layer.alert("移动失败,请重试!");
}
window.location.reload();
});
} //下移
function moveDown(obj,index,id) {
if(index == "${fn:length(examQuesList)}"){
layer.msg("下移到底了");
return;
}
var self = $(obj);
var _old = self.closest("tr.courseList");
var _new = self.closest("tr.courseList").next("tr");
if (_new.length > 0) {
var _temp = _old.html();
_old.empty().append(_new.html());
_new.empty().append(_temp);
}
var eSort = (currentPage-1)*showCount+parseInt(index)+1;
$.post("exampleQuestion/upDownMove.do",{E_SORT:eSort,ID:id,EXAMPLE_ID:"${pd.EXAMPLE_ID}"},function(data){
if(data != 'success'){
layer.alert("移动失败,请重试!");
}
window.location.reload();
});
}
javaWeb上移下移(SpringMVC+Mabits+MySql)的更多相关文章
- [手把手教程][JavaWeb]优雅的SpringMvc+Mybatis整合之路
来源于:http://www.jianshu.com/p/5124eef40bf0 [手把手教程][JavaWeb]优雅的SpringMvc+Mybatis整合之路 手把手教你整合最优雅SSM框架:S ...
- 解决springmvc+mybatis+mysql中文乱码问题【转】
这篇文章主要介绍了解决java中springmvc+mybatis+mysql中文乱码问题的相关资料,需要的朋友可以参考下 近日使用ajax请求springmvc后台查询mysql数据库,页面显示中文 ...
- php修改排序,上移下移
php修改排序,上移下移 /** $UpDown //移动方向,up或down $table //表名 $id //当前移动的ID $id_col //ID字段的名称 $ ...
- SpringMVC+Mybatis+MySQL配置Redis缓存
SpringMVC+Mybatis+MySQL配置Redis缓存 1.准备环境: SpringMVC:spring-framework-4.3.5.RELEASE-dist Mybatis:3.4.2 ...
- Quartz学习——SSMM(Spring+SpringMVC+Mybatis+Mysql)和Quartz集成详解(四)
当任何时候觉你得难受了,其实你的大脑是在进化,当任何时候你觉得轻松,其实都在使用以前的坏习惯. 通过前面的学习,你可能大致了解了Quartz,本篇博文为你打开学习SSMM+Quartz的旅程!欢迎上车 ...
- SpringMVC + MyBatis + Mysql + Redis(作为二级缓存) 配置
2016年03月03日 10:37:47 标签: mysql / redis / mybatis / spring mvc / spring 33805 项目环境: 在SpringMVC + MyBa ...
- SpringBoot(五)Springmvc+Mybatis+mysql
为了整合这个花了,好长时间,因为上几个连在一起,在pom文件中有没注释的配置,导致我找这个问题找了好久.下面开始 1,先new project 时选择spring initializr,新建好一个空项 ...
- jQuery实现表格行上移下移和置顶
jQuery实现表格行上移下移和置顶 我们在操作列表数据的时候,需要将数据行排列顺序进行调整,如上移和下移行,将行数据置顶等,这些操作都可以在前端通过点击按钮来完成,并且伴随着简单的动态效果,轻松实现 ...
- Quartz学习——SSMM(Spring+SpringMVC+Mybatis+Mysql)和Quartz集成详解(转)
通过前面的学习,你可能大致了解了Quartz,本篇博文为你打开学习SSMM+Quartz的旅程!欢迎上车,开始美好的旅程! 本篇是在SSM框架基础上进行的. 参考文章: 1.Quartz学习——Qua ...
随机推荐
- P3768 简单的数学题(莫比乌斯反演)
[题目链接] https://www.luogu.org/problemnew/show/P3768 [题目描述] 求 \(\sum_{i=1}^{n}\sum_{j=1}^{n}i* j* gcd( ...
- Windows任务计划创建计划,定时执行PowerShell命令
[环境介绍] 操作系统:Windows Server 2012 R2,64位操作系统 PowerShell版本:PowerShell 1.0 脚本位置:C:\BackUp.ps1 启动目录:C:\Wi ...
- tarjan算法,一个关于 图的联通性的神奇算法
一.算法简介 Tarjan 算法一种由Robert Tarjan提出的求解有向图强连通分量的算法,它能做到线性时间的复杂度. 我们定义: 如果两个顶点可以相互通达,则称两个顶点强连通(strongly ...
- tomcat故障——数据库未授权
- Windows10下设置Shift+右键增加cmd
https://blog.csdn.net/wyx0712/article/details/82120806
- 字符串 Instant 互转
Instant inst = Instant.now(); System.out.println(inst);//2018-05-15T02:27:09.909Z String s1 = s.subs ...
- sql server 字符串转table
-- ============================================= -- Author: gengc -- Create date: <2012-12-29> ...
- SpringBoot2.0.3整合Quartz2.3.0实现定时任务
转载:https://www.cnblogs.com/ealenxie/p/9134602.html 关于别人写的quartz学习的地址:https://blog.csdn.net/lkl_csdn/ ...
- Autel MaxiSys MS908CV Diagnostic System for Commercial Vehicles
As a new member of Autel’s MaxiSys family, the MaxiSys CV is built on the powerful MaxiSys 908 platf ...
- 12-----BBS论坛
BBS论坛(十二) 12.1.图形验证码生成 (1)utils/captcha/init.py import random import string # Image:一个画布 # ImageDraw ...