提交 3d491c62 authored 作者: 吴德鹏's avatar 吴德鹏

优化商品置顶排序

上级 ff3cf9ab
......@@ -295,12 +295,20 @@ public class TbCfStationItemController extends ApiBaseAction {
return R.error("交换失败");
}
@RequestMapping("/existItemSort")
/**
* 商品交换顺序
*
* @param itemId
* @param sort
* @return
*/
@RequestMapping("/exchangeItemSort")
@ResponseBody
public R existItemSort(@RequestParam("sort") Integer sort) {
boolean exist = tbCfStationItemService.existItemSort(sort);
return R.ok().put("exist", exist);
public R exchangeItemSort(@RequestParam("itemId") String itemId, @RequestParam("sort") Integer sort) {
int res = tbCfStationItemService.exchangeItemSort(itemId, sort);
if (res > 0) {
return R.ok();
}
return R.error("交换失败");
}
}
......@@ -108,5 +108,5 @@ public interface TbCfStationItemService {
int itemDownward(String itemId);
boolean existItemSort(Integer sort);
int exchangeItemSort(String itemId,Integer sort);
}
......@@ -552,9 +552,18 @@ public class TbCfStationItemServiceImpl implements TbCfStationItemService {
}
@Override
public boolean existItemSort(Integer sort) {
public int exchangeItemSort(String itemId, Integer sort) {
TbCfStationItemEntity exchangeItem = tbCfStationItemDao.queryItemBySort(sort);
TbCfStationItemEntity sourceItem = tbCfStationItemDao.queryObject(itemId);
if (exchangeItem != null) {
exchangeItem.setSort(sourceItem.getSort());
tbCfStationItemDao.update(exchangeItem);
}
sourceItem.setSort(sort);
return tbCfStationItemDao.queryItemBySort(sort) == null ? false : true;
return tbCfStationItemDao.update(sourceItem);
}
}
......@@ -482,15 +482,12 @@ let vm = new Vue({
saveOrUpdate: function (event) {
let flag = true
let exist = false
let url = '../tbcfstationitem/existItemSort?sort=' + vm.tbCfStationItem.sort;
let url = '../tbcfstationitem/exchangeItemSort?sort=' + vm.tbCfStationItem.sort + '&itemId=' + vm.tbCfStationItem.itemId;
Ajax.request({
url: url,
type: "GET",
contentType: "application/json",
successCallback: function (r) {
exist = r.exist
}
});
this.paramster.forEach(item => {
if (item.paramValue == '' || item.paramValue == null) {
......@@ -500,8 +497,6 @@ let vm = new Vue({
if (vm.prevItem.length === 0 || !flag) {
console.log(123);
alert('请编辑完属性或参数后再保存');
} else if (exist) {
alert('序号['+vm.tbCfStationItem.sort+']已存在');
} else {
let resArr = [];
this.prevItem.forEach(item => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论