html
<div style="font-size: 24px;margin-top: 15px;"><span>共{{total}}条记录,共{{number}}页。</span> <span>当前第{{page}}页,</span><span>本页{{physicalList.length}}数据</span></div>
<div align="center" style="font-size: 30px;margin-top: -37px;margin-left: 415px">
<a @click="goPage(1,total/pageSize)" id="first">首页</a>
<a @click="goPage(page-1,total/pageSize)" id="last">上一页</a>
<a @click="goPage(page+1,total/pageSize)" id="next">下一页</a>
<a @click="goPage(total/pageSize,total/pageSize)" id="finally">尾页</a>
</div>
<div class="mui-media-body"
style="margin:-10% 100px;height: 50px;width:140px;text-align: center;color: #ffffff;background-color: #1d90e6;border-radius: 20px;float: right">
<span @click="goback()"
style=" font-size: 24px;float: left;margin-top: 8px;margin-left: 11px;">
返回上一页
</span>
</div>
vue数据初始化
data: {
number:0,//总页数
page:1,//当前页
idCard:"",
name: "",
title: "",
flag: true,
orgid: '',
type: "",
physicalList: [],//用来存放全部数据
objectList:[],//用来存放每页的数据
pageSize:6,//每页显示的条数
total:0,//总条数
record:"",
forgid:""
}
数据初始化
created: function () {
let that = this;
let theRequest = new Object();
let currentUrl = window.location.search;
if (currentUrl.indexOf("?") != -1) {
let str = currentUrl.substr(1);
strs = str.split("&");
for (let i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
let queryType = "";
if (theRequest.type != null && theRequest.type != '') {
queryType = theRequest.type;
}
this.type = queryType;
if (queryType == "mz") {
this.title = "门诊";
this.flag = false;
}
if (queryType == "zy") {
this.title = "住院";
this.flag = true;
}
let postData = Qs.stringify({
type: queryType
})
let id = theRequest.id;
this.uid = id;
console.log(id)
that.idCard = theRequest.idCard;
let name = decodeURI(theRequest.name);
this.name = name;
console.log(this.name)
if (theRequest.orgid != null && theRequest.orgid != '') {
this.orgid = theRequest.orgid;
} else {
this.orgid = 120925;
}
that.forgid = theRequest.forgid;
axios.post(url + 'hra00_03/findChildrenInfoById?pid=' + this.uid + "&pageSize=10000"+"&page="+this.page+"&forgid="+this.forgid , {}, {
withCredentials: true,
changeOrigin: true
}).then(function (response) {
let result = response.data.data;
if (result.msgCode == 1000) {
that.title = result.title;
that.total = result.data.length;
that.number = Math.ceil(response.data.data.data.length/that.pageSize);
//中间页数
if(1<that.page && that.page<that.number){
$("#first").css("color", "#337ab7");
$("#last").css("color", "#337ab7");
$("#next").css("color", "#337ab7");
$("#finally").css("color", "#337ab7");
}else if (1 == Math.ceil((that.number))){//一共一页
$("#first").css("color", "#b6b6b6");
$("#last").css("color", "#b6b6b6");
$("#next").css("color", "#b6b6b6");
$("#finally").css("color", "#b6b6b6");
}else if (that.page == Math.ceil((that.number))){//最后一页
$("#first").css("color", "#337ab7");
$("#last").css("color", "#337ab7");
$("#next").css("color", "#b6b6b6");
$("#finally").css("color", "#b6b6b6");
}else if (that.page < Math.ceil((that.number)) && 1 == that.page){//第一页
$("#first").css("color", "#b6b6b6");
$("#last").css("color", "#b6b6b6");
$("#next").css("color", "#337ab7");
$("#finally").css("color", "#337ab7");
}
// that.number = Math.ceil(result.total/that.pageSize);
for (var i = 0; i < result.data.length; i++) {
if (result.data[i].sfrq != null) {
result.data[i].sfrq = result.data[i].sfrq.substr(0, 10)
}
}
if(that.total > that.pageSize){
for (var i = 0; i < that.pageSize; i++) {
that.objectList[i] = result.data[i];
}
}else{
for (var i = 0; i < that.total; i++) {
that.objectList[i] = result.data[i];
}
}
that.physicalList = result.data;
console.log(that.physicalList.length)
} else if (result.msgCode == 1001) {
console.log(result.message)
} else if (result.msgCode == 1002) {
console.log(result.message)
} else if (result.msgCode == 1003) {
console.log(result.message)
} else {
console.log(result.message)
}
console.log(result);
}).catch(function (error) {
console.log(error)
});
console.log(this.physicalList)
}
js代码
methods: {
gopath: function (id,sign) {
if(sign == '0'){
window.location =encodeURI(encodeURI( htmlUrl + "micopc/healthRecords/children/childrenInfo60.html?type=" + this.type + "&id=" + id + "&name=" + this.name+"&uid="+this.uid+"&forgid="+this.forgid));
}else if(sign == '1'){
window.location =encodeURI(encodeURI( htmlUrl + "micopc/healthRecords/children/childrenInfo61.html?type=" + this.type + "&id=" + id + "&name=" + this.name+"&uid="+this.uid+"&forgid="+this.forgid));
}else if(sign == '2'){
window.location =encodeURI(encodeURI( htmlUrl + "micopc/healthRecords/children/childrenInfo62.html?type=" + this.type + "&id=" + id + "&name=" + this.name+"&uid="+this.uid+"&forgid="+this.forgid ));
}else if(sign == '3'){
window.location =encodeURI(encodeURI( htmlUrl + "micopc/healthRecords/children/childrenInfo63.html?type=" + this.type + "&id=" + id + "&name=" + this.name+"&uid="+this.uid+"&forgid="+this.forgid));
}
},
goback: function () {
window.location.href = htmlUrl + "micopc/healthRecords/basicInfo/basicHome.html?idCard=" + this.idCard+"&forgid="+this.forgid;
},
goPage:function(page,checkPage){
let that = this;
that.objectList.splice(0,that.objectList.length);
if(page <= checkPage){
page = Math.ceil((page));
if(page==0){
page = 1;
}
if(page<1){
page = 1;
}
that.page = page;
if(page == 1){
for (var i = 0; i < that.pageSize; i++) {
that.objectList[i] = that.physicalList[(that.page)*(that.pageSize+i)-6];
}
}else{
if((that.page-1)*(that.pageSize)+that.pageSize > that.physicalList.length){
let listSize = that.physicalList.length - (that.page-1)*(that.pageSize)+that.pageSize - that.pageSize;
let end = (that.page-1)*(that.pageSize);
for (var i = 0; i < listSize; i++) {
that.objectList[i] = that.physicalList[end+i];
}
}else{
for (var i = 0; i < that.pageSize; i++) {
that.objectList[i] = that.physicalList[(that.page-1)*(that.pageSize)+i];
}
}
}
if(1<that.page && that.page<that.number){
$("#first").css("color", "#337ab7");
$("#last").css("color", "#337ab7");
$("#next").css("color", "#337ab7");
$("#finally").css("color", "#337ab7");
}else if (1 == Math.ceil((that.number))){//一共一页
$("#first").css("color", "#b6b6b6");
$("#last").css("color", "#b6b6b6");
$("#next").css("color", "#b6b6b6");
$("#finally").css("color", "#b6b6b6");
}else if (that.page == Math.ceil((that.number))){//最后一页
$("#first").css("color", "#337ab7");
$("#last").css("color", "#337ab7");
$("#next").css("color", "#b6b6b6");
$("#finally").css("color", "#b6b6b6");
}else if (that.page < Math.ceil((that.number)) && 1 == that.page){//第一页
$("#first").css("color", "#b6b6b6");
$("#last").css("color", "#b6b6b6");
$("#next").css("color", "#337ab7");
$("#finally").css("color", "#337ab7");
}
}else{
page = Math.ceil((checkPage));
if(checkPage <= 0){
page = 1;
}
that.page = page;
if(page == 1){
for (var i = 0; i < that.pageSize; i++) {
that.objectList[i] = that.physicalList[(that.page)*(that.pageSize+i)-6];
}
}else{
if((that.page-1)*(that.pageSize)+that.pageSize > that.physicalList.length){
let listSize = that.physicalList.length - (that.page-1)*(that.pageSize)+that.pageSize - that.pageSize;
let end = (that.page-1)*(that.pageSize);
for (var i = 0; i < listSize; i++) {
that.objectList[i] = that.physicalList[end+i];
}
}else{
for (var i = 0; i < that.pageSize; i++) {
that.objectList[i] = that.physicalList[(that.page-1)*(that.pageSize)+i];
}
}
}
//中间页数
if(1<that.page && that.page<that.number){
$("#first").css("color", "#337ab7");
$("#last").css("color", "#337ab7");
$("#next").css("color", "#337ab7");
$("#finally").css("color", "#337ab7");
}else if (1 == Math.ceil((that.number))){//一共一页
$("#first").css("color", "#b6b6b6");
$("#last").css("color", "#b6b6b6");
$("#next").css("color", "#b6b6b6");
$("#finally").css("color", "#b6b6b6");
}else if (that.page == Math.ceil((that.number))){//最后一页
$("#first").css("color", "#337ab7");
$("#last").css("color", "#337ab7");
$("#next").css("color", "#b6b6b6");
$("#finally").css("color", "#b6b6b6");
}else if (that.page < Math.ceil((that.number)) && 1 == that.page){//第一页
$("#first").css("color", "#b6b6b6");
$("#last").css("color", "#b6b6b6");
$("#next").css("color", "#337ab7");
$("#finally").css("color", "#337ab7");
}
}
}
}