初学avalon自己做的一个小页面

代码如下:

<link href="CSS/Index.css" type="text/css" rel="stylesheet"/>
<script src="JS/jquery-1.8.2.js"></script>
<script src="JS/avalon.js"></script>
<script>
//加载分页插件
require(["pager/avalon.pager"], function () {
var vm = avalon.define({
$id: "customer",
CustomerData: {},
Customer: "",
QueryDT: function () {
InData(vm.Customer, 10, 1, true);
},
RemoveDT: function (id, del) {
if (confirm("确定要删除吗?")) {
$.ajax({
url: "VM/Delete.ashx",
dataType: "html",
type: "post",
data: { "id": id },
success: function (data) {
if (data == "1") {
if (vm.CustomerData.size() > 10) {
del();
} else {
InData("", 10, 1, true);
}


} else {
alert("删除失败,请与管理员联系");
}
}
});
}

},
add: function () {
window.location.href = "/operation.html";
},
edit: function (id) {
window.location.href = "/operation.html?id="+id;
}
});

var vm1 = avalon.define({
$id: "page",
pager: {
totalItems: 1500,
onJump: function (e, data) {
InData(vm.Customer, 10, data.currentPage, false);
},
showJumper: true
},
$skipArray: [""]
});
vm1.pager.$watch("totalItems", function (a) {
var widget = avalon.vmodels.pp
if (widget) {
widget.totalItems = a;
widget.currentPage = 1;
}
});
function InData(customer, pagesize, pageindex, IsQuery) {
//获取数据
$.ajax({
url: "VM/Query.ashx",
dataType: "json",
type: "post",
data: { "customer": customer, "PageSize": pagesize, "PageIndex": pageindex, "Type": 1,"id":0 },
success: function (data) {
vm.CustomerData = data;
}
});
if (IsQuery) {
//获取总记录数
$.ajax({
url: "VM/Query.ashx",
dataType: "html",
type: "post",
data: { "customer": customer, "Type": 2 },
success: function (data) {
vm1.pager.totalItems = data;
}
});
}
avalon.scan();
}

InData("", 10, 1, true);

avalon.scan();
});
</script>
</head>
<body>
<div ms-controller="customer">
<div>客户代号:<input type="text" ms-duplex="Customer" />&nbsp;<input type="button" value="查找" ms-click="QueryDT()" />&nbsp;<input type="button" value="新增" ms-click="add" /></div>
<table width="100%" class="customerinfo">
<tr>
<th>Customer</th>
<th style="width:28%">CustName</th>
<th>EmployeeID</th>
<th>EmployeeName</th>
<th>Region</th>
<th>Country</th>
<th>BU</th>
<th>Tiers</th>
<th>NewGroup</th>
<th colspan="2">操作</th>
</tr>
<tr ms-repeat="CustomerData" ms-class="event:$index%2==1" ms-hover="hover" ms-if-loop="$index<10">
<td>{{el.Customer}}</td>
<td>{{el.Name}}</td>
<td>{{el.EmployeeID}}</td>
<td>{{el.EmployeeName}}</td>
<td>{{el.Region}}</td>
<td>{{el.Country}}</td>
<td>{{el.BU}}</td>
<td>{{el.Tiers}}</td>
<td>{{el.NewGroup}}</td>
<td><input type="button" ms-click="RemoveDT(el.ID,$remove)" value="删除" /></td>
<td><input type="button" ms-click="edit(el.ID)" value="编辑" /></td>
</tr>
</table>
</div>
<div ms-controller="page">
<div ms-widget="pager,pp"></div>
</div>

使用到了onui库中的分页插件地址: http://ued.qunar.com/oniui/index.html#!/widgets
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值