stuManage.vue 7.6 KB

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