table.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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>{{'项目'+(index+1)}}</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)" @click="onClickCheck"/> -->
  27. <checkbox :checked="Boolean(item.IsPublic)" disabled="false"/>
  28. </label>
  29. </checkbox-group>
  30. </th>
  31. </tr>
  32. </tbody>
  33. </table>
  34. <view class="m_right_footer">
  35. <view class="m_paging">
  36. <text class="m_paging_item m_paging_upper" v-show="bShowLastPageBtn" @click="last()">上一页</text>
  37. <text class="m_paging_item" :key="i" v-for="i in pageTotalNum" @click="paging(i)" :class="i==currentPage?'p_act':''">
  38. {{i}}
  39. </text>
  40. <text class="m_paging_item m_paging_lower" v-show="bShowNextPageBtn" @click="next()">下一页</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. name: "home_table",
  49. data() {
  50. return {
  51. index: 1,
  52. tabledata: [],
  53. pageTotalNum:1,
  54. currentPage:1,
  55. totalItem:5,
  56. bShowLastPageBtn:false,
  57. bShowNextPageBtn:false,
  58. }
  59. },
  60. components: {
  61. // locationtemp
  62. },
  63. mounted() {
  64. // this.getList();
  65. },
  66. methods: {
  67. paging(i) {
  68. uni.showLoading({
  69. title: '加载中'
  70. });
  71. let fromIndex = this.totalItem*(i-1);
  72. let toIndex = fromIndex+this.totalItem;
  73. let data = {
  74. "UserID": mydata_userInfo.UserID,
  75. "StartIndex": fromIndex, //用户数组索引
  76. "EndIndex": toIndex, //用户数组索引结束
  77. }
  78. console.log('data=',data)
  79. uni.request({
  80. header: {
  81. 'Content-Type': 'application/json;charset=UTF-8'
  82. },
  83. url: mydata_api + '/project/getprojects',
  84. method: 'POST',
  85. data: data,
  86. dataType: 'json',
  87. success: (res) => {
  88. //100成功
  89. if (res.data.Code == 100) {
  90. console.log("请求全部资产", res);
  91. this.tabledata = res.data.Projects;
  92. // console.log('res.data.TotalNum=',res.data.TotalNum)
  93. this.pageTotalNum = Math.ceil(res.data.TotalNum/this.totalItem);
  94. this.currentPage = i;
  95. this.showNextOrLastPageBtn();
  96. }
  97. //200失败
  98. else {
  99. console.log('suc200', res);
  100. }
  101. uni.hideLoading();
  102. },
  103. fail: (res) => {
  104. console.log("请求失败****");
  105. uni.hideLoading();
  106. }
  107. });
  108. },
  109. initPage() {
  110. this.paging(1);
  111. },
  112. last()
  113. {
  114. this.currentPage--;
  115. this.paging(this.currentPage);
  116. },
  117. next()
  118. {
  119. this.currentPage++;
  120. this.paging(this.currentPage);
  121. },
  122. showNextOrLastPageBtn()
  123. {
  124. if(this.pageTotalNum==this.currentPage)
  125. {
  126. this.bShowLastPageBtn = true;
  127. this.bShowNextPageBtn = false;
  128. // console.log('11111')
  129. }
  130. else if(1==this.currentPage)
  131. {
  132. this.bShowLastPageBtn = false;
  133. this.bShowNextPageBtn = true;
  134. // console.log('2222')
  135. }
  136. else
  137. {
  138. this.bShowLastPageBtn = true;
  139. this.bShowNextPageBtn = true;
  140. // console.log('333333')
  141. }
  142. if(this.pageTotalNum==1){
  143. this.bShowLastPageBtn = false;
  144. this.bShowNextPageBtn = false;
  145. // console.log('444444')
  146. }
  147. },
  148. getList() {
  149. this.initPage(1);
  150. // uni.request({
  151. // url: mydata_api + "/project/getprojects",
  152. // data: {
  153. // "UserID": mydata_userInfo.UserID
  154. // },
  155. // method: "POST",
  156. // dataType: "json",
  157. // success: res => {
  158. // this.tabledata = res.data.Projects
  159. // console.log('tabledata=',this.tabledata)
  160. // // let aData = {
  161. // // "CreateTime": "2020-01-01 00:00:00",
  162. // // "CreateUserID": "59458299-3b84-4895-98f6-b990cdaedc72",
  163. // // "CreateUserName": "朱峰",
  164. // // "Describe": '“实验以振兴国产科技电影”和“实现中国航天强国梦”的宏大蓝图为背景,以我国首次登陆火星计划为现实脚本,运用现场实时特效技术手段,对火星地面、外太空等场景进行“经典学习”和“实践创兴”并通过持续开发和学生在实验过程中的资源上传不断扩大现场创作的实景和虚拟资产库,使学生再学习过程中,即是资源学习者和方案讨论者,也是资源建设者',
  165. // // "Id": 30,
  166. // // "ProjectName": "《火星计划》",
  167. // // "ProjectReviewImage": "../../../assets/studentAndTeacher/table/marsPlanReviewImage.png",
  168. // // "ReviewImageOss": "../../../assets/studentAndTeacher/table/marsPlanMainCover.png",
  169. // // "Type": "科幻",
  170. // // }
  171. // // this.tabledata.unshift(aData);
  172. // // console.log("table页面请求所有项目",res);
  173. // this.$forceUpdate();//强制刷新页面
  174. // }
  175. // })
  176. },
  177. //查看项目
  178. find(obj,index){
  179. this.$emit('viewProject',obj,index);
  180. },
  181. onClickCheck(e){
  182. if(this.bPublic==true){
  183. this.bPublic = false;
  184. } else {
  185. this.bPublic = true;
  186. }
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss">
  192. .m_right {
  193. width: 100%;
  194. height: px2vh(960);
  195. margin-top: 5rpx;
  196. // padding: 0 150rpx;
  197. background-color: #fff;
  198. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  199. .m_right_container {
  200. padding: 150rpx;
  201. }
  202. .s_logo {
  203. width: 100%;
  204. // height: 800rpx;
  205. }
  206. .m_right_hander {
  207. text-align: right;
  208. height: 250rpx;
  209. position: relative;
  210. .m_btn_red {
  211. position: absolute;
  212. height: 80rpx;
  213. line-height: 80rpx;
  214. padding: 0 40rpx;
  215. right: 0;
  216. top: 50%;
  217. transform: translateY(-50%);
  218. background: #EA252C;
  219. color: #fff;
  220. }
  221. }
  222. }
  223. tbody tr {
  224. border-top: 2rpx solid #DDDDDD !important;
  225. }
  226. tbody tr th:first-child {
  227. position: relative;
  228. }
  229. tbody tr th {
  230. font-weight: 400 !important;
  231. height: 140rpx;
  232. line-height: 140rpx;
  233. }
  234. tbody tr:hover {
  235. // color: #fff;
  236. background: #FDEBEC;
  237. // opacity: 0.08;
  238. }
  239. .m-table-hander {
  240. background-color: #FFF8F7;
  241. height: 140rpx;
  242. line-height: 140rpx;
  243. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  244. font-weight: bold;
  245. }
  246. .m_edit {
  247. position: absolute;
  248. top: 50%;
  249. left: 50%;
  250. transform: translate(-50%, -50%);
  251. background: rgb(67, 127, 250);
  252. color: rgb(255, 255, 255);
  253. min-width: 130rpx;
  254. }
  255. .m_delete {
  256. position: absolute;
  257. top: 50%;
  258. left: 50%;
  259. min-width: 130rpx;
  260. transform: translate(-50%, -50%);
  261. background: rgb(234, 37, 44);
  262. color: rgb(255, 255, 255);
  263. z-index: 3;
  264. }
  265. .m_right_footer {
  266. margin-top: 80rpx;
  267. }
  268. .m_logoimg {
  269. width: 80rpx;
  270. height: 80rpx;
  271. position: absolute;
  272. top: 50%;
  273. left: 50%;
  274. transform: translate(-50%, -50%);
  275. }
  276. .m_paging {
  277. text-align: right;
  278. .m_paging_item {
  279. padding: 10rpx 18rpx;
  280. border: 1rpx solid #DDDDDD;
  281. border-radius: 8rpx;
  282. margin-right: 10rpx;
  283. }
  284. .p_act {
  285. background: #EA252C;
  286. color: #fff;
  287. border: inherit;
  288. }
  289. }
  290. .m_paging_item:hover {
  291. background: #EA252C;
  292. color: #fff;
  293. border: inherit;
  294. }
  295. .m_act1 {
  296. color: #FF0019;
  297. }
  298. </style>