1.填充
1.1
$("#FullPomotions").datagrid({
title: ' ',
animate: true,
rownumbers: false,
collapsible: false,
idField: 'id',
singleSelect: true,
fitColumns: true,
url: '',
columns: [[
{ field: 'id', title: 'id', width: 10, hidden: true },
{ field: 'activeName', title: '活动名称', width: 100 },
{ field: 'activeDescribe', title: '活动描述', width: 100 },
{ field: 'SpecialNote', title: '特殊说明', width: 100 },
{ field: 'activeTimeStart', title: '开始时间', width: 100 },
{ field: 'activeTimeEnd', title: '结束时间', width: 100 },
{ field: 'Contributive', title: '出资方', width: 100 },
{
field: 'action', title: '操作', width: 100, align: 'center',
formatter: function (value, row, index) {
//row.ID,数据id(主键)
var a = '编辑 ';
var b = ' 删除';
return a + b;
}
}
]],
});
1.2 待更新
- 添加
//这里用的是input的classname
$('#FullPromotionBox').form('load', {
ID:'',
ActiveName: '',
activeDescribe: '',
SpecialNote: '',
activeTimeStart: '',
activeTimeEnd:'',
Contributive: ''
});
AddorEditPromotion("添加满额促销");
3.删除
function Delete(id) {
if (id == null) {
$.messager.alert("系统提示", "请选择要删除的信息!");
return;
}
$.messager.confirm('系统提示', '是否删除,删除后不可恢复,请慎重删除', function (r) {
if (r) {
$.post('/FullPromotion/DeleteFullPromotion?id=' + id,
function (data) {
if (data.result) {
$.messager.show({
width: 200,
height: 100,
msg: '删除活动成功',
title: "删除活动"
});
Refresh();
} else {
$.messager.alert('系统提示', data.msg, 'error');
}
});
}
});
}
4.修改
function Update(id) {
var selectRow = $('#FullPomotions').datagrid('getSelected');
if (selectRow == null) {
$.messager.alert("系统提示", "请选择要修改的信息!");
return;
}
AddorEditPromotion("修改满额促销");
$('#FullPromotionBox').form('load', {
ID:selectRow.id,
ActiveName: selectRow.activeName,
activeDescribe: selectRow.activeDescribe,
SpecialNote: selectRow.SpecialNote,
activeTimeStart: selectRow.activeTimeStart,
activeTimeEnd: selectRow.activeTimeEnd,
Contributive: selectRow.Contributive
});
}
5.刷新
function Refresh() {
$('#FullPomotions').datagrid("reload");
}
6.函数
AddorEditPromotion = function (data) {
$('#FullPromotion').show().dialog({
title: data,
width: 393,
height: 267,
modal: true,
collapsible: false,
minimizable: false,
maximizable: false,
buttons: [{
text: '取消',
iconCls: 'icon-cancel',
handler: function () {
$.messager.confirm('提示', '确认取消创建或修改活动?', function (b) {
if (b) {
$('#FullPromotion').dialog('close');
} else {
//alert('取消');
}
});
}
}, {
text: '确定',
iconCls: 'icon-ok',
handler: function () {
if (!ClickCheckSubmit()) {
return;
}
if ($('#FullPromotionBox').form('validate')) {
$.messager.progress({
text: '正在保存....',
interval: 100
});
$.ajax({
type: 'post',
url: '/FullPromotion/EditFullPromotion',
data: $("#FullPromotionBox").serialize(),
error: function () { $.messager.alert('系统提示', '提交数据到服务器失败!', 'error'); },
success: function (data) {
if (data.result) {
$.messager.show({
width: 200,
height: 100,
msg: '数据保存成功!',
title: "保存数据"
});
$.messager.progress("close");
$('#FullPromotion').dialog('close');
Refresh();
$.messager.alert('系统提示', data.msg, 'success');
} else {
$.messager.progress("close");
$.messager.alert('系统提示', data.msg, 'error');
}
}
})
}
}
}]
});
}
- 验证
function ClickCheckSubmit() {
var activeName = $("#txtActiveName").val();
if ($.trim(activeName) == "") {
$.messager.alert('系统提示', "活动名称不能为空", 'error');
return false;
}
var describe = $("#txtActiveDescribe").val();
if ($.trim(describe) == "") {
$.messager.alert('系统提示', "活动描述不能为空", 'error');
return false;
}
var txtStartTime = $("#txtStartTime").datetimebox('getValue');
if ($.trim(txtStartTime) == "") {
$.messager.alert('系统提示', "活动时间不能为空", 'error');
return false;
}
var txtEndTime = $("#txtEndTime").datetimebox('getValue');
if ($.trim(txtEndTime) == "") {
$.messager.alert("系统提示", "活动时间不能为空", 'error');
return false;
}
var contributive = $("#Contributive").combobox("getValue");
if ($.trim(contributive) == "") {
$.messager.alert('系统提示', "请选择出资方", 'error');
return false;
}
return true;
}
8.html 代码