stuManage.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view class="m_right">
  3. <view class="stu_box" v-show="!isShowAdd">
  4. <view class="m_right_hander">
  5. <button size="mini" class="m_btn_red" @click="onClick_addStudent">添加学生</button>
  6. </view>
  7. <view class="m_right_container">
  8. <table style="width: 100%;border: 1px solid #DDDDDD;border-collapse: collapse">
  9. <thead class="m-table-hander">
  10. <tr>
  11. <th>用户名</th>
  12. <th>姓名</th>
  13. <th>班级</th>
  14. <th>试验进度</th>
  15. <th>成绩</th>
  16. <th>实验情况</th>
  17. </tr>
  18. </thead>
  19. <tbody>
  20. <tr v-for="(student,studentI) in curPageStudentList" :key="studentI">
  21. <th style="color: #EA252C;">{{student.userName}}</th>
  22. <th>{{student.name}}</th>
  23. <th>{{student.class}}</th>
  24. <th>{{student.progress}}</th>
  25. <th>{{student.score}}</th>
  26. <th style="position: relative;"><button type="default" size="mini" class="m_delete">实验情况</button></th>
  27. </tr>
  28. </tbody>
  29. </table>
  30. </view>
  31. <view class="m_right_footer">
  32. <view class="m_paging">
  33. <text class="m_paging_item m_paging_upper" @click="onClick_last" v-show="pageCount>1">上一页</text>
  34. <text class="m_paging_item" :key="i" v-for="i in pageCount" @click="paging(i)" :class="i==index?'p_act':''">
  35. {{i}}
  36. </text>
  37. <text class="m_paging_item m_paging_lower" @click="onClick_next" v-show="pageCount>1">下一页</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="df" v-show="isShowAdd">
  42. <view class="addStu-box df fdc aic">
  43. <view class="box2-table-box-left df fdc aic ">
  44. <view class="box2-table-box-left-item df fdr aic jcsb">
  45. <view class="table-title">用户名</view>
  46. <!-- <textarea class="addStu-textarea" :placeholder="addStuRule" v-model="addStudentData.IlabAccount"></textarea> -->
  47. <input class="form-input" name="input" placeholder="请输入" v-model="addStudentData.IlabAccount" />
  48. </view>
  49. </view>
  50. <view class="addStu-addBox df jcfe">
  51. <button class="addStu-addBtn df jcc aic" @click="onClick_addStu_add">添加</button>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. name: "manager_user",
  60. data() {
  61. return {
  62. isShowAdd: false,
  63. //当前页数
  64. index: 1,
  65. //总计页数
  66. pageCount: 0,
  67. //所有学生
  68. allStudent: null,
  69. //当前页学生
  70. curPageStudentList: [{
  71. "userName": '',
  72. "name": '',
  73. "class": '',
  74. "progress": '',
  75. "score": '',
  76. }],
  77. //老师添加学生数据例
  78. addStudentData: {
  79. "IlabAccount": ""
  80. },
  81. addStuRule: '请输入用户名,多个用户名之间请用“;”符号隔开',
  82. }
  83. },
  84. methods: {
  85. paging(index) {
  86. this.index = index;
  87. this.updateTable();
  88. },
  89. onClick_last() {
  90. if (this.index > 1) {
  91. this.index--;
  92. this.updateTable();
  93. }
  94. },
  95. onClick_next() {
  96. if (this.index < this.pageCount) {
  97. this.index++;
  98. this.updateTable();
  99. }
  100. },
  101. onClick_addStudent() {
  102. this.isShowAdd = true;
  103. },
  104. updateInfo() {
  105. this.index = 1;
  106. this.allStudent = userController.studentList;
  107. this.pageCount = Math.ceil(this.allStudent.length / 7);
  108. this.updateTable();
  109. // console.log("学生管理,更新页面", this.allStudent);
  110. },
  111. updateTable() {
  112. this.curPageStudentList = [];
  113. for (let i = 0; i < 7; i++) {
  114. let student = this.allStudent[(this.index - 1) * 7 + i];
  115. if (student) {
  116. let astudent = {
  117. "userName": student.IlabAccount,
  118. "name": student.Name,
  119. "class": student.Class,
  120. "progress": '',
  121. "score": student.Scores.Score,
  122. }
  123. this.curPageStudentList.push(astudent);
  124. }
  125. }
  126. // console.log("当前页学生列表", this.curPageStudentList);
  127. },
  128. onClick_addStu_add() {
  129. // console.log(this.addStudentData);
  130. let self = this;
  131. // let data=[
  132. // {
  133. // "IlabAccount":'test'
  134. // },
  135. // {
  136. // "IlabAccount":'mj_2728179'
  137. // }
  138. // ]
  139. // let addData=this.addStudentData.IlabAccount;
  140. MyRequest.AddUsers([this.addStudentData], function(res) {
  141. // console.log("请求添加成功,返回值", res);
  142. // self.updateInfo();
  143. self.isShowAdd = false;
  144. self.addStudentData = {};
  145. userController.updateStudentList(self.updateInfo,null)
  146. }, null);
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. .addStu-box {
  153. // margin-left: px2vw(100);
  154. margin-top: px2vw(50);
  155. }
  156. .addStu-table {
  157. margin-top: px2vw(50);
  158. width: 100%;
  159. border: 1px solid #DDDDDD;
  160. border-collapse: collapse;
  161. background: #f9f9f9;
  162. }
  163. .addStu-input {
  164. // border: solid 1px #DDDDDD;
  165. width: 100%;
  166. height: 100%;
  167. }
  168. .addStu-addBox {
  169. width: 100%;
  170. margin-top: px2vw(20);
  171. }
  172. .addStu-addBtn {
  173. width: px2vw(158);
  174. height: px2vw(48);
  175. background: #EA252C;
  176. border-radius: px2vw(8);
  177. font-size: px2vw(18);
  178. color: #FFFFFF;
  179. line-height: px2vw(24);
  180. margin-top: px2vw(31);
  181. margin-bottom: px2vw(65);
  182. }
  183. .form-input {
  184. width: px2vw(355);
  185. height: px2vw(54);
  186. padding: px2vw(14) px2vw(20);
  187. font-size: px2vw(20);
  188. color: #070707;
  189. line-height: px2vw(26);
  190. background: #FFFFFF;
  191. border-radius: px2vw(4);
  192. border: 1px solid #B4B4B4;
  193. }
  194. .box2-table-box-left {
  195. // width: px2vw(1000);
  196. width: px2vw(500);
  197. }
  198. .box2-table-box-left-item {
  199. width: 100%;
  200. margin-top: px2vw(30);
  201. }
  202. .table-title {
  203. font-size: px2vw(22);
  204. color: #555555;
  205. line-height: px2vw(29);
  206. }
  207. .addStu-textarea {
  208. width: px2vw(800);
  209. height: px2vw(500);
  210. padding: px2vw(14) px2vw(20);
  211. font-size: px2vw(20);
  212. color: #070707;
  213. line-height: px2vw(26);
  214. background: #FFFFFF;
  215. border-radius: px2vw(4);
  216. border: 1px solid #B4B4B4;
  217. }
  218. .m_right {
  219. width: 100%;
  220. height: 100%;
  221. margin-top: 5rpx;
  222. padding: 0 150rpx;
  223. background-color: #fff;
  224. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  225. .m_right_hander {
  226. text-align: right;
  227. height: 250rpx;
  228. position: relative;
  229. .m_btn_red {
  230. position: absolute;
  231. height: 80rpx;
  232. line-height: 80rpx;
  233. padding: 0 40rpx;
  234. right: 0;
  235. top: 50%;
  236. transform: translateY(-50%);
  237. background: #EA252C;
  238. color: #fff;
  239. }
  240. }
  241. }
  242. tbody tr {
  243. border-top: 2rpx solid #DDDDDD !important;
  244. }
  245. tbody tr th {
  246. font-weight: 400 !important;
  247. height: 140rpx;
  248. line-height: 140rpx;
  249. }
  250. tbody tr:hover {
  251. // color: #fff;
  252. background: #FDEBEC;
  253. // opacity: 0.08;
  254. }
  255. .m-table-hander {
  256. background-color: #FFF8F7;
  257. height: 140rpx;
  258. line-height: 140rpx;
  259. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  260. font-weight: bold;
  261. }
  262. .m_edit {
  263. position: absolute;
  264. top: 50%;
  265. left: 50%;
  266. transform: translate(-50%, -50%);
  267. background: rgb(67, 127, 250);
  268. color: rgb(255, 255, 255);
  269. min-width: 130rpx;
  270. }
  271. .m_delete {
  272. position: absolute;
  273. top: 50%;
  274. left: 50%;
  275. min-width: 130rpx;
  276. transform: translate(-50%, -50%);
  277. background: rgb(234, 37, 44);
  278. color: rgb(255, 255, 255);
  279. }
  280. .m_right_footer {
  281. margin-top: 80rpx;
  282. margin-bottom: 80rpx;
  283. }
  284. .m_paging {
  285. text-align: right;
  286. .m_paging_item {
  287. padding: 10rpx 18rpx;
  288. border: 1rpx solid #DDDDDD;
  289. border-radius: 8rpx;
  290. margin-right: 10rpx;
  291. }
  292. .p_act {
  293. background: #EA252C;
  294. color: #fff;
  295. border: inherit;
  296. }
  297. }
  298. .m_paging_item:hover {
  299. background: #EA252C;
  300. color: #fff;
  301. border: inherit;
  302. }
  303. .m_act1 {
  304. color: #FF0019;
  305. }
  306. .m_right_container {
  307. // width: px2vw(1377);
  308. }
  309. .stu_box {
  310. width: px2vw(1377);
  311. }
  312. </style>