<!DOCTYPE html><html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml"><head><meta charset="UTF-8"><title>特产信息</title><script src="js/jquery-2.1.4.min.js"></script><link rel="stylesheet" href="https://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css"><script src="https://apps.bdimg.com/libs/bootstrap/3.2.0/js/bootstrap.min.js"></script><script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script><script src="https://unpkg.com/axios/dist/axios.min.js"></script><style>body{overflow-x:hidden;}a{color: #35b558;}li a:hover {color:orangered;font-size: 15px;}a:link{text-decoration: none;}.btn{width: 100px !important;}.lineOne {text-align: left;}.div-td-content-more {position: absolute;height: auto;z-index: 999;line-height: 20px;background-color: #d3e8fd;padding: 8px 6px;border: 1px solid #e8e8ea;display: none;}table td{border-bottom: 10px solid #666666;/*下面4行是实现超过td文字变省略号,另外还要给table加上table-layout:fixed;*/text-overflow:ellipsis;-moz-text-overflow:ellipsis;overflow:hidden;white-space: nowrap;}</style><script src="js/main.js"></script><link rel="stylesheet" href="css/main.css"><script>$(function () {$("body").on("click", ".lineOne", function (e) {if ($(".div-td-content-more").is(":hidden")) {var text = $(this).text();if (text != "") {text = "<i></i>" + text;$(".div-td-content-more").html(text).css({"width": $(this).outerWidth() + "px","left": $(this).offset().left,"top": ($(this).offset().top + $(this).outerHeight()) + "px"}).show();e.stopPropagation();}} else {$(".div-td-content-more").hide();}});$("body").on("click", ".div-td-content-more", function (e) {e.stopPropagation();});$("body").on("click", function () {$(".div-td-content-more").hide();});});</script></head><body style="width: 1070px;height: 800px;"><div id="app" v-cloak><div style="margin-left: 30px;margin-top: 30px" class="col-md-3" role="complementary"></div><div class="div-td-content-more"><i></i></div><div style="width: 880px;float: left"><div class="form-group"><input v-model="conditionParam" style="display: inline-table" class="form-control search" placeholder="请输入特产名称" ><input style="margin-left: 80px" type="button" @click="search()" class=" btn btn-primary" value="搜索"><input type="button" @click="plDel()" class=" btn btn-primary" value="批量删除"><input type="button" id="add" @click="show()" value="新增" class=" btn btn-primary"></div><h3 style="text-align: center">特产列表</h3><table class="table table-bordered table-hover table-striped" style="margin-top: 40px;table-layout: fixed"><tr style="display:none"><td style="width:10%"></td><td style="width:20%"></td><td style="width:50%"></td><td style="width: 20%"></td></tr><!-- <tr class="center text-center table-bottom" ><td colspan="5" ><span class="text-center">特产列表</span></td></tr>--><tr class="center text-center" style="background-color:#e3f1d4"><td style="width: 10%">序号</td><td style="width: 20%">特产名称</td><td style="width: 50%">特产简介</td><td style="width: 20%">操作</td></tr><tr class="text-center" v-for="(list,index) in lists"><td><input type="checkbox" name="checkbox" :value="list.id" v-model="ids">{{(pager.requestPage-1)*pageSize+index+1}}</td><td>{{list.specialName}}</td><td class="lineOne">{{list.text}}</td><td><a @click="update(list.id)" style="cursor: pointer" href="javascript:void(0)">修改</a> <a @click="del(list.id)" style="cursor: pointer" href="javascript:void(0)">删除</a></td></tr></table><span class="span-top" style="float: left;">显示第{{(pager.requestPage-1)*pageSize+1}}到第{{pager.recordCount>pager.requestPage*pageSize ? pager.requestPage*pageSize:pager.recordCount}}条记录,总共{{pager.recordCount}}条记录,每页显示<select v-model="pageSize" @change="limit()"><option value="5">5</option><option value="10">10</option><option value="20">20</option></select>条记录</span><div class="page-bar "><ul><li><a v-on:click="btnClick(1)">第一页</a></li><li v-if="pager.requestPage>1"><a v-on:click="pager.requestPage--,pageClick()">上一页</a></li><li v-if="pager.requestPage==1"><a class="banclick">上一页</a></li><li v-for="index in indexs" v-bind:class="{ 'active': pager.requestPage == index}"><a v-on:click="btnClick(index)">{{ index }}</a></li><li v-if="pager.requestPage!=pager.pageCount"><a v-on:click="pager.requestPage++,pageClick()">下一页</a></li><li v-if="pager.requestPage == pager.pageCount"><a class="banclick">下一页</a></li><li><a>共 {{pager.pageCount}} 页</a></li><li><a v-on:click="btnClick( Math.ceil(pager.recordCount/pageSize))">最后一页</a></li></ul></div></div></div></body><script>var app=new Vue({el:'#app',data:{lists:[],ids:[],pager:{recordCount:'',pageCount: 8, //总页数requestPage: 1//当前页码},conditionParam:'',pageSize:5,},methods:{show:function () {location.href="specialDetail.html";},limit:function () {var that=this;axios.post(server.ip+'/special/getSpecialList.json',{pageSize:that.pageSize}).then(function (r) {that.lists=r.data.data.sendData.records;that.pager=r.data.data.sendData.pager;});},plDel:function () {var that=this;if (confirm("确认删除?")) {axios.post(server.ip + '/special/pldelById.json', {ids: that.ids.toString()}).then(function (r) {var flag = r.data.e.descalert(flag);location.href = "special.html";});}},search:function () {var that=this;that.pager.requestPage=this.pager.requestPage;axios.post(server.ip+'/special/getSpecialList.json',{conditionParam:that.conditionParam,pageSize:that.pageSize,requestPage:that.pager.requestPage}).then(function (r) {that.lists=r.data.data.sendData.records;that.pager=r.data.data.sendData.pager;});},btnClick: function(data){//页码点击事件var that=this;that.pager.requestPage=data;axios.post(server.ip+'/special/getSpecialList.json',{conditionParam:that.conditionParam,pageSize:that.pageSize,requestPage:that.pager.requestPage}).then(function (r) {that.lists=r.data.data.sendData.records;});},pageClick: function(){var that=this;that.pager.requestPage=this.pager.requestPage;axios.post(server.ip+'/special/getSpecialList.json',{conditionParam:that.conditionParam,pageSize:that.pageSize,requestPage:that.pager.requestPage}).then(function (r) {that.lists=r.data.data.sendData.records;});},back:function () {location.href="index.html";},del:function (id) {if (confirm("确认删除?")) {axios.post(server.ip + '/special/delById.json', {id: id}).then(function (r) {var flag = r.data.e.desc;alert(flag);location.href = "special.html";});}},update:function (id) {window.location.href="specialDetail.html?state=update&&id="+id;}},mounted:function () {var that=this;axios.post(server.ip+'/special/getSpecialList.json',{pageSize:that.pageSize}).then(function (r) {that.lists=r.data.data.sendData.records;that.pager=r.data.data.sendData.pager;});},computed: {indexs: function(){var left = 1;var right = this.pager.pageCount;var ar = [];if(this.pager.pageCount>= 5){if(this.pager.requestPage > 3 && this.pager.requestPage < this.pager.pageCount-2){left = this.pager.requestPage - 2right = this.pager.requestPage + 2}else{if(this.pager.requestPage<=3){left = 1right = 5}else{right = this.pager.pageCountleft = this.pager.pageCount -4}}}while (left <= right){ar.push(left)left ++}return ar}}})</script></html>
lineOne点击显示缩略的内容。
<tr style="display:none"><td style="width:10%"></td><td style="width:20%"></td><td style="width:50%"></td><td style="width: 20%"></td></tr>
设置字段的宽度,因为设置了table-layout: fixed
**
table td{border-bottom: 10px solid #666666;/*下面4行是实现超过td文字变省略号,另外还要给table加上table-layout:fixed;*/text-overflow:ellipsis;-moz-text-overflow:ellipsis;overflow:hidden;white-space: nowrap;}
多余文本省略号显示。
