table.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="m_right">
  3. <img src="../../assets/home/topImg.jpg" class="s_logo" mode=""></img>
  4. <view class="m_right_container">
  5. <table style="width: 100%;border: 1px solid #DDDDDD;border-collapse: collapse">
  6. <thead class="m-table-hander">
  7. <tr>
  8. <th>项目</th>
  9. <th>名称</th>
  10. <th>类型</th>
  11. <th>创建人</th>
  12. <th>查看</th>
  13. <th>是否为公共</th>
  14. </tr>
  15. </thead>
  16. <tbody>
  17. <tr v-for="(item,index) in tabledata" :key="index">
  18. <th>{{item.Id}}</th>
  19. <th>{{item.ProjectName}}</th>
  20. <th>{{item.Type}}</th>
  21. <th>{{item.CreateUserName}}</th>
  22. <th style="position: relative;"><button type="default" @click="find(item,index)" size="mini" class="m_delete">查看</button></th>
  23. <th>
  24. <checkbox-group>
  25. <label>
  26. <checkbox :checked="Boolean(item.IsPublic)" disabled="false"/>
  27. </label>
  28. </checkbox-group>
  29. </th>
  30. </tr>
  31. </tbody>
  32. </table>
  33. <view class="m_right_footer">
  34. <view class="m_paging">
  35. <text class="m_paging_item m_paging_upper" v-show="bShowLastPageBtn" @click="last()">上一页</text>
  36. <text class="m_paging_item" :key="i" v-for="i in pageTotalNum" @click="paging(i)" :class="i==currentPage?'p_act':''">
  37. {{i}}
  38. </text>
  39. <text class="m_paging_item m_paging_lower" v-show="bShowNextPageBtn" @click="next()">下一页</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. name: "student_table",
  48. data() {
  49. return {
  50. index: 1,
  51. tabledata: [],
  52. pageTotalNum:1,
  53. currentPage:1,
  54. totalItem:2,
  55. bShowLastPageBtn:false,
  56. bShowNextPageBtn:false,
  57. }
  58. },
  59. methods: {
  60. // paging(obj) {
  61. // this.index = obj;
  62. // },
  63. paging(i) {
  64. uni.showLoading({
  65. title: '加载中'
  66. });
  67. let fromIndex = this.totalItem*(i-1);
  68. let toIndex = fromIndex+this.totalItem;
  69. let data = {
  70. "UserID": mydata_userInfo.UserID,
  71. "BeginNum": fromIndex, //用户数组索引
  72. "EndNum": toIndex, //用户数组索引结束
  73. }
  74. uni.request({
  75. header: {
  76. 'Content-Type': 'application/json;charset=UTF-8'
  77. },
  78. url: mydata_api + '/project/getprojects',
  79. method: 'POST',
  80. data: data,
  81. dataType: 'json',
  82. success: (res) => {
  83. //100成功
  84. if (res.data.Code == 100) {
  85. console.log("请求全部资产", res);
  86. this.tabledata = res.data.Items;
  87. this.pageTotalNum = Math.ceil(res.data.TotalNum/this.totalItem);
  88. this.currentPage = i;
  89. this.showNextOrLastPageBtn();
  90. }
  91. //200失败
  92. else {
  93. console.log('suc200', res);
  94. }
  95. uni.hideLoading();
  96. },
  97. fail: (res) => {
  98. console.log("请求失败****");
  99. uni.hideLoading();
  100. }
  101. });
  102. },
  103. initPage() {
  104. this.paging(1);
  105. },
  106. last()
  107. {
  108. this.currentPage--;
  109. this.paging(this.currentPage);
  110. },
  111. next()
  112. {
  113. this.currentPage++;
  114. this.paging(this.currentPage);
  115. },
  116. showNextOrLastPageBtn()
  117. {
  118. if(this.pageTotalNum==this.currentPage)
  119. {
  120. this.bShowLastPageBtn = true;
  121. this.bShowNextPageBtn = false;
  122. // console.log('11111')
  123. }
  124. else if(1==this.currentPage)
  125. {
  126. this.bShowLastPageBtn = false;
  127. this.bShowNextPageBtn = true;
  128. // console.log('2222')
  129. }
  130. else
  131. {
  132. this.bShowLastPageBtn = true;
  133. this.bShowNextPageBtn = true;
  134. // console.log('333333')
  135. }
  136. if(this.pageTotalNum==1){
  137. this.bShowLastPageBtn = false;
  138. this.bShowNextPageBtn = false;
  139. // console.log('444444')
  140. }
  141. },
  142. getList() {
  143. // uni.request({
  144. // url: mydata_api + "/project/getprojects",
  145. // data: {
  146. // "UserID": mydata_userInfo.UserID
  147. // },
  148. // method: "POST",
  149. // dataType: "json",
  150. // success: res => {
  151. // this.tabledata = res.data.Projects
  152. // // console.log('tabledata=',this.tabledata)
  153. // this.$forceUpdate();//强制刷新页面
  154. // }
  155. // })
  156. this.initPage(1);
  157. },
  158. find(obj,index){
  159. this.$emit('viewProject',obj,index);
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. .m_right {
  166. width: 100%;
  167. margin-top: 5rpx;
  168. // padding: 0 150rpx;
  169. background-color: #fff;
  170. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  171. .m_right_container {
  172. padding: 150rpx;
  173. }
  174. .s_logo {
  175. width: 100%;
  176. }
  177. .m_right_hander {
  178. text-align: right;
  179. height: 250rpx;
  180. position: relative;
  181. .m_btn_red {
  182. position: absolute;
  183. height: 80rpx;
  184. line-height: 80rpx;
  185. padding: 0 40rpx;
  186. right: 0;
  187. top: 50%;
  188. transform: translateY(-50%);
  189. background: #EA252C;
  190. color: #fff;
  191. }
  192. }
  193. }
  194. tbody tr {
  195. border-top: 2rpx solid #DDDDDD !important;
  196. }
  197. tbody tr th:first-child {
  198. position: relative;
  199. }
  200. tbody tr th {
  201. font-weight: 400 !important;
  202. height: 140rpx;
  203. line-height: 140rpx;
  204. }
  205. tbody tr:hover {
  206. // color: #fff;
  207. background: #FDEBEC;
  208. // opacity: 0.08;
  209. }
  210. .m-table-hander {
  211. background-color: #FFF8F7;
  212. height: 140rpx;
  213. line-height: 140rpx;
  214. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  215. font-weight: bold;
  216. }
  217. .m_edit {
  218. position: absolute;
  219. top: 50%;
  220. left: 50%;
  221. transform: translate(-50%, -50%);
  222. background: rgb(67, 127, 250);
  223. color: rgb(255, 255, 255);
  224. min-width: 130rpx;
  225. }
  226. .m_delete {
  227. position: absolute;
  228. top: 50%;
  229. left: 50%;
  230. min-width: 130rpx;
  231. transform: translate(-50%, -50%);
  232. background: rgb(234, 37, 44);
  233. color: rgb(255, 255, 255);
  234. z-index: 100;
  235. }
  236. .m_right_footer {
  237. margin-top: 80rpx;
  238. }
  239. .m_logoimg {
  240. width: 80rpx;
  241. height: 80rpx;
  242. position: absolute;
  243. top: 50%;
  244. left: 50%;
  245. transform: translate(-50%, -50%);
  246. }
  247. .m_paging {
  248. text-align: right;
  249. .m_paging_item {
  250. padding: 10rpx 18rpx;
  251. border: 1rpx solid #DDDDDD;
  252. border-radius: 8rpx;
  253. margin-right: 10rpx;
  254. }
  255. .p_act {
  256. background: #EA252C;
  257. color: #fff;
  258. border: inherit;
  259. }
  260. }
  261. .m_paging_item:hover {
  262. background: #EA252C;
  263. color: #fff;
  264. border: inherit;
  265. }
  266. .m_act1 {
  267. color: #FF0019;
  268. }
  269. </style>