1. <!DOCTYPE html>
    2. <html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>特产信息</title>
    6. <script src="js/jquery-2.1.4.min.js"></script>
    7. <link rel="stylesheet" href="https://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css">
    8. <script src="https://apps.bdimg.com/libs/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    9. <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    10. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    11. <style>
    12. body{
    13. overflow-x:hidden;
    14. }
    15. a{
    16. color: #35b558;
    17. }
    18. li a:hover {
    19. color:orangered;
    20. font-size: 15px;
    21. }
    22. a:link{
    23. text-decoration: none;
    24. }
    25. .btn{
    26. width: 100px !important;
    27. }
    28. .lineOne {
    29. text-align: left;
    30. }
    31. .div-td-content-more {
    32. position: absolute;
    33. height: auto;
    34. z-index: 999;
    35. line-height: 20px;
    36. background-color: #d3e8fd;
    37. padding: 8px 6px;
    38. border: 1px solid #e8e8ea;
    39. display: none;
    40. }
    41. table td{
    42. border-bottom: 10px solid #666666;
    43. /*下面4行是实现超过td文字变省略号,另外还要给table加上table-layout:fixed;*/
    44. text-overflow:ellipsis;
    45. -moz-text-overflow:ellipsis;
    46. overflow:hidden;
    47. white-space: nowrap;
    48. }
    49. </style>
    50. <script src="js/main.js"></script>
    51. <link rel="stylesheet" href="css/main.css">
    52. <script>
    53. $(function () {
    54. $("body").on("click", ".lineOne", function (e) {
    55. if ($(".div-td-content-more").is(":hidden")) {
    56. var text = $(this).text();
    57. if (text != "") {
    58. text = "<i></i>" + text;
    59. $(".div-td-content-more").html(text).css({
    60. "width": $(this).outerWidth() + "px",
    61. "left": $(this).offset().left,
    62. "top": ($(this).offset().top + $(this).outerHeight()) + "px"
    63. }).show();
    64. e.stopPropagation();
    65. }
    66. } else {
    67. $(".div-td-content-more").hide();
    68. }
    69. });
    70. $("body").on("click", ".div-td-content-more", function (e) {
    71. e.stopPropagation();
    72. });
    73. $("body").on("click", function () {
    74. $(".div-td-content-more").hide();
    75. });
    76. });
    77. </script>
    78. </head>
    79. <body style="width: 1070px;height: 800px;">
    80. <div id="app" v-cloak>
    81. <div style="margin-left: 30px;margin-top: 30px" class="col-md-3" role="complementary">
    82. </div>
    83. <div class="div-td-content-more"><i></i></div>
    84. <div style="width: 880px;float: left">
    85. <div class="form-group">
    86. <input v-model="conditionParam" style="display: inline-table" class="form-control search" placeholder="请输入特产名称" >
    87. <input style="margin-left: 80px" type="button" @click="search()" class=" btn btn-primary" value="搜索">
    88. <input type="button" @click="plDel()" class=" btn btn-primary" value="批量删除">
    89. <input type="button" id="add" @click="show()" value="新增" class=" btn btn-primary">
    90. </div>
    91. <h3 style="text-align: center">特产列表</h3>
    92. <table class="table table-bordered table-hover table-striped" style="margin-top: 40px;table-layout: fixed">
    93. <tr style="display:none">
    94. <td style="width:10%"></td>
    95. <td style="width:20%"></td>
    96. <td style="width:50%"></td>
    97. <td style="width: 20%"></td>
    98. </tr>
    99. <!-- <tr class="center text-center table-bottom" >
    100. <td colspan="5" ><span class="text-center">特产列表</span></td>
    101. </tr>-->
    102. <tr class="center text-center" style="background-color:#e3f1d4">
    103. <td style="width: 10%">序号</td>
    104. <td style="width: 20%">特产名称</td>
    105. <td style="width: 50%">特产简介</td>
    106. <td style="width: 20%">操作</td>
    107. </tr>
    108. <tr class="text-center" v-for="(list,index) in lists">
    109. <td><input type="checkbox" name="checkbox" :value="list.id" v-model="ids">
    110. {{(pager.requestPage-1)*pageSize+index+1}}</td>
    111. <td>{{list.specialName}}</td>
    112. <td class="lineOne">{{list.text}}</td>
    113. <td><a @click="update(list.id)" style="cursor: pointer" href="javascript:void(0)">修改</a>&nbsp;&nbsp; <a @click="del(list.id)" style="cursor: pointer" href="javascript:void(0)">删除</a></td>
    114. </tr>
    115. </table>
    116. <span class="span-top" style="float: left;">显示第{{(pager.requestPage-1)*pageSize+1}}到第{{pager.recordCount>pager.requestPage*pageSize ? pager.requestPage*pageSize:pager.recordCount}}条记录,总共{{pager.recordCount}}条记录,每页显示
    117. <select v-model="pageSize" @change="limit()">
    118. <option value="5">5</option>
    119. <option value="10">10</option>
    120. <option value="20">20</option>
    121. </select>条记录
    122. </span>
    123. <div class="page-bar ">
    124. <ul>
    125. <li><a v-on:click="btnClick(1)">第一页</a></li>
    126. <li v-if="pager.requestPage>1"><a v-on:click="pager.requestPage--,pageClick()">上一页</a></li>
    127. <li v-if="pager.requestPage==1"><a class="banclick">上一页</a></li>
    128. <li v-for="index in indexs" v-bind:class="{ 'active': pager.requestPage == index}">
    129. <a v-on:click="btnClick(index)">{{ index }}</a>
    130. </li>
    131. <li v-if="pager.requestPage!=pager.pageCount"><a v-on:click="pager.requestPage++,pageClick()">下一页</a></li>
    132. <li v-if="pager.requestPage == pager.pageCount"><a class="banclick">下一页</a></li>
    133. <li><a>共&nbsp;{{pager.pageCount}}&nbsp;页</a></li>
    134. <li><a v-on:click="btnClick( Math.ceil(pager.recordCount/pageSize))">最后一页</a></li>
    135. </ul>
    136. </div>
    137. </div>
    138. </div>
    139. </body>
    140. <script>
    141. var app=new Vue({
    142. el:'#app',
    143. data:{
    144. lists:[],
    145. ids:[],
    146. pager:{
    147. recordCount:'',
    148. pageCount: 8, //总页数
    149. requestPage: 1//当前页码
    150. },
    151. conditionParam:'',
    152. pageSize:5,
    153. },
    154. methods:{
    155. show:function () {
    156. location.href="specialDetail.html";
    157. },
    158. limit:function () {
    159. var that=this;
    160. axios.post(server.ip+'/special/getSpecialList.json',{pageSize:that.pageSize})
    161. .then(function (r) {
    162. that.lists=r.data.data.sendData.records;
    163. that.pager=r.data.data.sendData.pager;
    164. });
    165. },
    166. plDel:function () {
    167. var that=this;
    168. if (confirm("确认删除?")) {
    169. axios.post(server.ip + '/special/pldelById.json', {ids: that.ids.toString()})
    170. .then(function (r) {
    171. var flag = r.data.e.desc
    172. alert(flag);
    173. location.href = "special.html";
    174. });
    175. }
    176. },
    177. search:function () {
    178. var that=this;
    179. that.pager.requestPage=this.pager.requestPage;
    180. axios.post(server.ip+'/special/getSpecialList.json',{conditionParam:that.conditionParam,pageSize:that.pageSize,requestPage:that.pager.requestPage})
    181. .then(function (r) {
    182. that.lists=r.data.data.sendData.records;
    183. that.pager=r.data.data.sendData.pager;
    184. });
    185. },
    186. btnClick: function(data){//页码点击事件
    187. var that=this;
    188. that.pager.requestPage=data;
    189. axios.post(server.ip+'/special/getSpecialList.json',{conditionParam:that.conditionParam,pageSize:that.pageSize,requestPage:that.pager.requestPage})
    190. .then(function (r) {
    191. that.lists=r.data.data.sendData.records;
    192. });
    193. },
    194. pageClick: function(){
    195. var that=this;
    196. that.pager.requestPage=this.pager.requestPage;
    197. axios.post(server.ip+'/special/getSpecialList.json',{conditionParam:that.conditionParam,pageSize:that.pageSize,requestPage:that.pager.requestPage})
    198. .then(function (r) {
    199. that.lists=r.data.data.sendData.records;
    200. });
    201. },
    202. back:function () {
    203. location.href="index.html";
    204. },
    205. del:function (id) {
    206. if (confirm("确认删除?")) {
    207. axios.post(server.ip + '/special/delById.json', {id: id})
    208. .then(function (r) {
    209. var flag = r.data.e.desc;
    210. alert(flag);
    211. location.href = "special.html";
    212. });
    213. }
    214. },
    215. update:function (id) {
    216. window.location.href="specialDetail.html?state=update&&id="+id;
    217. }
    218. },
    219. mounted:function () {
    220. var that=this;
    221. axios.post(server.ip+'/special/getSpecialList.json',{pageSize:that.pageSize})
    222. .then(function (r) {
    223. that.lists=r.data.data.sendData.records;
    224. that.pager=r.data.data.sendData.pager;
    225. });
    226. },
    227. computed: {
    228. indexs: function(){
    229. var left = 1;
    230. var right = this.pager.pageCount;
    231. var ar = [];
    232. if(this.pager.pageCount>= 5){
    233. if(this.pager.requestPage > 3 && this.pager.requestPage < this.pager.pageCount-2){
    234. left = this.pager.requestPage - 2
    235. right = this.pager.requestPage + 2
    236. }else{
    237. if(this.pager.requestPage<=3){
    238. left = 1
    239. right = 5
    240. }else{
    241. right = this.pager.pageCount
    242. left = this.pager.pageCount -4
    243. }
    244. }
    245. }
    246. while (left <= right){
    247. ar.push(left)
    248. left ++
    249. }
    250. return ar
    251. }
    252. }
    253. })
    254. </script>
    255. </html>

    lineOne点击显示缩略的内容。

    1. <tr style="display:none">
    2. <td style="width:10%"></td>
    3. <td style="width:20%"></td>
    4. <td style="width:50%"></td>
    5. <td style="width: 20%"></td>
    6. </tr>

    设置字段的宽度,因为设置了table-layout: fixed
    **

    1. table td{
    2. border-bottom: 10px solid #666666;
    3. /*下面4行是实现超过td文字变省略号,另外还要给table加上table-layout:fixed;*/
    4. text-overflow:ellipsis;
    5. -moz-text-overflow:ellipsis;
    6. overflow:hidden;
    7. white-space: nowrap;
    8. }

    多余文本省略号显示。