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