文章已移至: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();
});
}

最新文章

  1. HDU 4791 Alice&#39;s Print Service(2013长沙区域赛现场赛A题)
  2. win7的svchost.exe占用内存过高如何解决
  3. Winform调用百度地图接口
  4. js注册验证【转】
  5. HDU 2614 Beat 深搜DFS
  6. oracle锁表解决方法
  7. 张羿给的删除重复数据的mssql语句
  8. 修改select选中项
  9. 【转】Python之道
  10. Linux内存解读
  11. CentOS下双网卡双IP不同IP段配置
  12. 【漏洞公告】高危:Windows系统 SMB/RDP远程命令执行漏洞
  13. 全栈性能测试修炼宝典--Jmeter实战(二)
  14. Win7下如何使用GCC编译器
  15. 【RF库Collections测试】Set List Value
  16. [JSOI2009]电子字典 hash
  17. Spring 集合注入
  18. mysql登录:access denied for user &#39;root&#39;@&#39;localhost&#39;(using password:YES)
  19. hdoj--2187--悼念512汶川大地震遇难同胞——老人是真饿了(贪心)
  20. 了解固态硬盘SSD,竟然如此简单!小白也能懂!

热门文章

  1. ie浏览器(Internet Explorer)不播放背景音乐
  2. Luogu P1608 路径统计 最短路计数
  3. javaEE 转发 和 重定向
  4. Windows下 virtualenv 使用
  5. Yii2 前台控制器访问权限控制
  6. Charles抓包使用总结
  7. [inner] bug
  8. 07-spring之三大框架的整合
  9. Cannot convert value &#39;0000-00-00 00:00:00&#39; from column 1 to TIMESTAMP解决办法
  10. GitKraken使用教程-基础部分(6)