增加文章、商品列表修改排序功能

This commit is contained in:
2021-01-11 00:21:24 +08:00
parent 7ed117d054
commit 372265d89a
8 changed files with 183 additions and 26 deletions
@@ -111,7 +111,7 @@
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 25, //每页的记录行数(*)
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
search: true, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: true,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
@@ -132,37 +132,47 @@
title: '所属分类'
}, {
field: 'Title',
title: '商品标题'
title: '商品标题',
}, {
field: 'Price',
title: '商品价格'
},
{
field: 'Sequence',
title: '排序'
title: '排序',
width: 130,
formatter: function (value, row, index) {
return '<div class="input-group"><input type="number" class="form-control" id="ac_rank_' + row["Id"] + '" name="ac_rank_' + row["Id"] + '" value="' + value + '" placeholder="请输入一个数字,越小排越前"><a class="input-group-addon btn btn-primary" title="修改保存" href="javascript:;" onclick="doSaveSequence(' + row["Id"] + ')"><i class="fa fa-save"></i></a></div>'
}
}, {
field: 'AddTime',
title: '添加时间'
title: '添加时间',
width: 150
}, {
field: 'IsNew',
title: '最新',
align: 'center',
formatter: 'newFormatter'
formatter: 'newFormatter',
width: 65
}, {
field: 'IsRecommend',
title: '推荐',
align: 'center',
formatter: 'recommendFormatter'
formatter: 'recommendFormatter',
width: 65
}, {
field: 'IsHide',
title: '隐藏',
align: 'center',
formatter: 'hideFormatter'
formatter: 'hideFormatter',
width: 65
},
{
field: 'Id',
title: '操作',
formatter: 'actionFormatter'
formatter: 'actionFormatter',
width: 140
}
]
});
@@ -223,7 +233,45 @@
};
return oInit;
};
};
function doSaveSequence(id) {
var rank = $("#ac_rank_" + id).val();
if (rank == '') {
layer.alert("请输入排序!", { icon: 2 });
return false;
}
//console.log(rank);
if (!isInt(rank)) {
layer.alert("排序只能是数字!", { icon: 2 });
return false;
}
var loading = layer.load(0, {
shade: [0.2, '#000'] //0.1透明度的背景
});
$.ajax({
type: "POST",
url: "/AdminCP/Product/DoEditProductSequence",
data: { id: id, rank: rank },
dataType: "JSON",
success: function (data) {
if (data.status == "success") {
layer.close(loading);
layer.msg(data.message, {
time: 1000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
//window.location.href = window.location.href;
});
} else {
layer.close(loading);
layer.alert(data.message, { icon: 2 });
}
},
error: function () {
layer.close(loading);
layer.alert('执行错误,请联系管理员!', { icon: 2 });
}
});
}
</script>
</div>
</div>