验证中...
Snippet 1 Snippet 2
easyui
Raw Copy
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
<*include file="header_easyui.html"*>
<div class="easyui-tabs" fit="true">
<div title="专属支付宝个人账号配置" iconCls="icon-user2">
<div id="mainlayout" class="easyui-layout" data-options="fit:true, collapsible:false">
<div data-options="region:'center',split:false, collapsible:false, border:false"
style="width: 1500px; height: 800px;">
<table id="tt1" toolbar="#tb1" fit="true" fitColumns="true"></table>
</div>
<div id="tb1" style="padding: 3px;">
<a href="javascript:void(0)" class="easyui-linkbutton" id="add" iconCls="icon-addnew"
onclick="insert(1)">添加</a> <span style="color: #cc1234"> </span>
</div>
</div>
</div>
</div>
<script>
var statuscfg = [
{type: 0, name: '下线'},
{type: 1, name: '上线'}
];
var vip = [
{type: 0, name: 'VIP0'},
{type: 1, name: 'VIP1'},
{type: 2, name: 'VIP2'},
{type: 3, name: 'VIP3'},
{type: 4, name: 'VIP4'},
{type: 5, name: 'VIP5'},
{type: 6, name: 'VIP6'},
{type: 7, name: 'VIP7'},
{type: 8, name: 'VIP8'},
{type: 9, name: 'VIP9'},
{type: 10, name: 'VIP10'},
{type: 11, name: 'VIP11'},
{type: 12, name: 'VIP12'},
{type: 13, name: 'VIP13'},
{type: 14, name: 'VIP14'},
{type: 15, name: 'VIP15'}
];
//定义全局变量(多table页根据需求新增)
var rowsLeng1 = -1;//总行数--填加新行的索引
var editIndex1 = undefined;//当前编辑的行
$(function () {
//数据行(根据需求修改)
var num1 = 1;
$('#tt' + num1).datagrid({
singleSelect: true,
pagination: true,
pageSize: 50,
idField: 'id',
url: 'exclusiveProxyAlipay.php?act=getlist',
columns: [[
{field: 'id', title: 'ID', width: 40, rowspan: 2},
{
field: 'account',
title: '支付宝账号',
width: 140,
rowspan: 1,
align: 'center',
editor: {
type: 'text',
options: {required: true, validType: ['length[1,60]']}
}
},
{
field: 'name',
title: '支付宝认证的实名',
width: 126,
rowspan: 1,
align: 'center',
editor: {
type: 'text',
options: {required: true, validType: ['length[1,40]']}
}
},
{
field: 'title',
title: '前端显示名称',
width: 120,
rowspan: 1,
align: 'center',
editor: {
type: 'text',
options: {required: true, validType: ['length[1,40]']}
}
},
{
field: 'min_pay',
title: '最小支付金额',
width: 100,
rowspan: 1,
align: 'center',
editor: {
type: 'numberbox',
options: {required: true, min: 0, precision: 2, validType: ['length[1,12]']}
}
},
{
field: 'max_pay',
title: '最大支付金额',
width: 100,
rowspan: 1,
align: 'center',
editor: {
type: 'numberbox',
options: {required: true, min: 0, precision: 2, validType: ['length[1,12]']}
}
},
{
field: 'max_pay_day',
title: '每日支付限额',
width: 100,
rowspan: 1,
align: 'center',
editor: {
type: 'numberbox',
options: {required: true, min: 0, precision: 2, validType: ['length[1,12]']}
}
},
{
field: 'show_vip',
title: '可见VIP',
id: "show_vip",
width: 360,
rowspan: 1,
align: 'center',
formatter: function (value) {
var name = '';
for (var i = 0; i < vip.length; i++) {
for (var k in value) {
if (vip[i].type == value[k]) name += vip[i].name + '; ';
}
}
return name;
},
editor: {
type: 'combobox',
options: {
multiple: true,
valueField: 'type',
textField: 'name',
data: vip,
editable: false,
onChange: function (values) {
for (var i in values) {
if (values[i] === '') {
values.splice(i, 1)
}
}
$(this).combobox('setValues', values);
}
}
}
},
{
field: 'lower_float',
title: '下浮金额',
width: 80,
rowspan: 1,
align: 'center',
editor: {
type: 'numberbox',
options: {required: true, min: 0, precision: 2, validType: ['length[1,12]']}
}
},
{
field: 'sleep_time',
title: '支付间隔(秒)',
width: 60,
rowspan: 1,
align: 'center',
editor: {
type: 'numberbox',
options: {required: true, min: 0, max: 1800, precision: 0, validType: ['length[1,4]']}
}
},
{
field: 'status', title: '状态', width: 80, align: 'center',
formatter: function (value) {
for (var i = 0; i < statuscfg.length; i++) {
if (statuscfg[i].type == value) {
if (value == 1) {
return "<span style='color: #FF03C6'>" + statuscfg[i].name + "</span>";
}
return statuscfg[i].name;
}
}
return value;
},
editor: {
type: 'combobox',
options: {
valueField: 'type',
textField: 'name',
data: statuscfg,
editable: false,
required: true,
}
}
},
{
field: 'day_pay',
title: '当日累计充值金额',
width: 110,
rowspan: 1,
align: 'center',
},
{
field: 'pay',
title: '累计充值金额',
width: 140,
rowspan: 1,
align: 'center',
},
{
field: 'aname',
title: '最后操作人',
width: 80,
rowspan: 1,
align: 'center',
},
{
field: 'remake',
title: '操作记录',
width: 70,
rowspan: 1,
align: 'center',
},
{
field: 'c_time',
title: '添加时间',
width: 140,
rowspan: 1,
align: 'center',
},
{
field: 'u_time',
title: '修改时间',
width: 140,
rowspan: 1,
align: 'center',
},
{
field: 'action', title: 'Action', width: 110, rowspan: 1, align: 'center',
formatter: function (value, row, index) {
if (!isNaN(row.id)) {
if (row.editing) {
var s = ' <a href="#" onclick="saverow(this,' + index + ')">Save</a> ';
var c = ' <a href="#" onclick="cancelrow(this,' + index + ',1)">Cancel</a> ';
return s + c;
} else {
var d = ' <a href="#" onclick="deleterow(this,' + index + ',' + row.id + ')">删除</a> ';
var e = " <a href='#' onclick='editrow(this," + index + ", 1, " + JSON.stringify(row) + ")'>编辑</a> ";
var f = " <a href='#' onclick='copyrow(" + num1 + ", " + JSON.stringify(row) + ")'>复制</a> ";
return f + e + d;
}
}
}
}
]],
onBeforeEdit: function (index, row) {
row.editing = true;
updateActions(index, num1);
},
onAfterEdit: function (index, row) {
row.editing = false;
updateActions(index, num1);
},
onCancelEdit: function (index, row) {
row.editing = false;
updateActions(index, num1);
}
});
});
function updateActions(index, num) {
$('#tt' + num).datagrid('updateRow', {
index: index,
row: {}
});
}
function getRowIndex(target) {
var tr = $(target).closest('tr.datagrid-row');
return parseInt(tr.attr('datagrid-row-index'));
}
//编辑
function editrow(target, index, num, row) {
if (window["editIndex" + num] !== undefined) {
$('#tt' + num).datagrid('rejectChanges', getRowIndex(target));
}
if (endEditing(num, false)) {
window['editIndex' + num] = index;//给editIndex对象赋值,index为当前行的索引
} else {
$('#dg').datagrid('selectRow', window['editIndex' + num]); // 选中一行
return false;
}
$('#tt' + num).datagrid('beginEdit', getRowIndex(target));//开始编辑
//老数据指定的列禁止编辑 -- 插入新行可以编辑
disabledColumns(index, num)
//编辑时多选重新赋值
setMultipleSelectionsValues(index, row, num)
}
//禁止编辑的列
function disabledColumn(index, field, num, type) {
var ed = $('#tt' + num).datagrid('getEditor', {index: index, field: field});//获取指定的编辑器
//禁止编辑
if (!type) {
$(ed.target).attr("disabled", true);
} else {
$(ed.target).combobox('disable');//禁止编辑
}
}
//多选重新赋值
function setMultipleSelectionValues(index, field, row, num) {
var ed = $('#tt' + num).datagrid('getEditor', {index: index, field: field});//获取指定的编辑器
//禁止编辑
$(ed.target).combobox('setValues', row[field]);
}
//获取多选的值
function getMultipleSelectionValues(index, field, num) {
var ed = $('#tt' + num).datagrid('getEditor', {index: index, field: field});//获取指定的编辑器
//获取值
var values = [];
values.push($(ed.target).combobox('getValues'));
//重新赋值
$(ed.target).combobox('setValues', values);
return values[0];
}
//取消编辑
function cancelrow(target, index, num) {
$('#tt' + num).datagrid('cancelEdit', getRowIndex(target));
resetRowsLeng(index, num, true);//取消编辑新增行的删除
}
//重置总行
function resetRowsLeng(index, num, del) {
if (index == window["rowsLeng" + num]) {
window["rowsLeng" + num] = -1;
if (del) $('#tt' + num).datagrid('deleteRow', index);//删除行
} else {
$('#tt' + num).datagrid('cancelEdit', window["editIndex" + num]);//当前行编辑事件取消
}
}
//限制编辑一行数据
function endEditing(num, del) {
if (window["editIndex" + num] == undefined) {
return true;
}//如果为undefined的话,为真,说明可以编辑
if ($('#tt' + num).datagrid('validateRow', window["editIndex" + num])) {
resetRowsLeng(window["editIndex" + num], num, del);
window["editIndex" + num] = undefined;
return true;//重置编辑行索引对象,返回真,允许编辑
} else {
return false;
}//否则,为假,返回假,不允许编辑
}
//插入数据
function insert(num, rowData) {
if (window['rowsLeng' + num] == -1) {
var row = $('#tt' + num).datagrid('getRows');
index = row.length;//获取最大行, 从后面插入
} else {
index = window['rowsLeng' + num];
}
if (endEditing(num, true)) {
window['editIndex' + num] = index;//给editIndex对象赋值,index为当前行的索引
} else {
$('#dg').datagrid('selectRow', window['editIndex' + num]);//选中一行
return false;
}
window['rowsLeng' + num] = index;
if (rowData === undefined) {
rowData = window["insert" + num](index);
} else {
//给主键赋值
rowData.id = index + 1;
}
$('#tt' + num).datagrid('insertRow', {
index: index,
row: rowData,
});
$('#tt' + num).datagrid('beginEdit', index);//开始编辑
//插入时多选重新赋值
setMultipleSelectionsValues(index, rowData, num)
}
//禁止编辑的列(根据需求修改)
function disabledColumns(index, num) {
disabledColumn(index, 'account', num, 0)
disabledColumn(index, 'name', num, 0)
}
//多选项新增编辑时重新赋值(根据需求修改)
function setMultipleSelectionsValues(index, row, num) {
setMultipleSelectionValues(index, 'show_vip', row, num)
}
//插入的数据(根据需求修改)
function insert1(index) {
var row = {
id: index + 1,
account: '',
title: '支付宝-',
name: '',
status: 0,
min_pay: 10.00,
max_pay: 200.00,
max_pay_day: 10000.00,
show_vip: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
lower_float: 0.10,
sleep_time: 120,
day_pay: 0.00,
pay: 0.00,
aname: '<*$username*>',
};
return row;
}
//拷贝(根据需求修改)
function copyrow(num, row) {
var rowData = {
account: '',
title: '支付宝-',
name: '',
status: row.status,
min_pay: row.min_pay,
max_pay: row.max_pay,
max_pay_day: row.max_pay_day,
show_vip: row.show_vip,
lower_float: row.lower_float,
sleep_time: row.sleep_time,
day_pay: row.day_pay,
pay: row.pay,
aname: '<*$username*>',
}
insert(num, rowData);
}
//保存(根据需求修改)
function saverow(target, index) {
var num = 1;
//保存数据先获取多选编辑时的数据然后重新赋值(根据需求修改)
var show_vip = getMultipleSelectionValues(index, 'show_vip', num);
//获取编辑后的数据-1
$('#tt' + num).datagrid('endEdit', getRowIndex(target));
var row = $('#tt' + num).datagrid('getData');
var endrow = row.rows[index];
//验证部分数据-2
var on = false; //验证数据标识
if (!on && $.trim(endrow.account) === '') {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 支付宝账号不能为空</span>');
on = true;
}
if (!on && $.trim(endrow.name) === '') {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 支付宝认证的实名不能为空</span>');
on = true;
}
if (!on && $.trim(endrow.title) === '') {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 前端显示名称不能为空</span>');
on = true;
}
if (!on && !/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(endrow.min_pay)) {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 最小支付金额必须为整数或小数(两位)</span>');
on = true;
}
if (!on && !/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(endrow.max_pay)) {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 最大支付金额必须为整数或小数(两位)</span>');
on = true;
}
if (!on && Number(endrow.min_pay) >= Number(endrow.max_pay)) {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 最大支付金额必须大于最小支付金额</span>');
on = true;
}
if (!on && !/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(endrow.max_pay_day)) {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 每日支付限额必须为整数或小数(两位)</span>');
on = true;
}
if (!on && Number(endrow.max_pay) > Number(endrow.max_pay_day)) {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 每日支付限额必须大于最大支付金额</span>');
on = true;
}
if (!on && !/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(endrow.lower_float)) {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 下浮金额必须为整数或小数(两位)</span>');
on = true;
}
if (!on && !/(^[1-9]([0-9]+){1,3}$)|(^(0){1}$)/.test(endrow.sleep_time)) {
$.messager.alert('错误消息', '<span style="color: #0d86c4"> 支付间隔时间必须为整数</span>');
on = true;
}
//验证失败后的处理
if (on) {
if (index != window['rowsLeng' + num]) {
$('#tt' + num).datagrid('rejectChanges', getRowIndex(target));//验证失败数据回滚-新增的不要回滚
}
$('#tt' + num).datagrid('beginEdit', index);//开始编辑, 回到编辑的行
//编辑时多选重新赋值
setMultipleSelectionsValues(index, endrow, num);
return false;
}
$.messager.confirm("操作提示", "确认要保存该数据?", function (data) {
if (data) {
if (index == window['rowsLeng' + num]) {
endrow.act = 'add';
} else {
endrow.act = 'edit';
}
endrow.show_vip = show_vip;
$.ajax({
url: 'exclusiveProxyAlipay.php',
type: 'post',
data: endrow,
dataType: 'json',
error: function () {
$('#tt' + num).datagrid('beginEdit', index);// 数据提交失败,开始编辑, 回到编辑的行
},
success: function (msg) {
if (msg.error) {
$.messager.alert("系统提示", msg.error);
$('#tt' + num).datagrid('beginEdit', index);// 数据提交失败,开始编辑, 回到编辑的行
//编辑时多选重新赋值
setMultipleSelectionsValues(index, endrow, num);
} else {
window['rowsLeng' + num] = -1;
$.messager.alert("系统提示", "数据保存成功");
$('#tt' + num).datagrid("reload");
}
}
});
} else {
$('#tt' + num).datagrid('rejectChanges', getRowIndex(target));//取消保存 数据回滚
resetRowsLeng(index, num, false);//取消保存 新增行删除
}
});
}
//删除(根据需求修改)
function deleterow(target, index, id) {
var num = 1;
$.messager.confirm('消息', '确认要删除该条记录?', function (r) {
if (r) {
$.ajax({
url: 'exclusiveProxyAlipay.php',
type: 'post',
data: {id: id, act: "delete"},
dataType: 'json',
error: function (error) {
$.messager.alert("系统提示", '删除失败!!!');
},
success: function (msg) {
if (msg.error) {
$.messager.alert("系统提示", msg.error);
$('#tt' + num).datagrid("reload");
} else {
$('#tt' + num).datagrid('deleteRow', getRowIndex(target));//删除
$.messager.alert("系统提示", "删除成功");
$('#tt' + num).datagrid("reload");
}
}
});
}
});
}
</script>
<*include file="_footer.html"*>
图片1.png

Comment list( 0 )

You need to Sign in for post a comment

Help Search