stuManage.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. // let data=[
  135. // {
  136. // "IlabAccount":'test'
  137. // },
  138. // {
  139. // "IlabAccount":'mj_2728179'
  140. // }
  141. // ]
  142. // let addData=this.addStudentData.IlabAccount;
  143. MyRequest.AddUsers([this.addStudentData], function(res) {
  144. console.log("请求添加成功,返回值", res);
  145. if(res.data.Users[0].State == 2)
  146. {
  147. alert("该学生不存在");
  148. return;
  149. }
  150. // self.updateInfo();
  151. self.isShowAdd = false;
  152. self.addStudentData = {};
  153. userController.updateStudentList(self.updateInfo,null)
  154. }, null);
  155. },
  156. onClick_XSSYQK(studentI){
  157. console.log("实验情况studentI=",studentI);
  158. let UserID = this.allStudent[studentI].UserID;
  159. console.log("UserID=",this.allStudent[studentI].UserID);
  160. this.$emit('onClick_XSSYQK',UserID);
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss">
  166. .addStu-box {
  167. // margin-left: px2vw(100);
  168. margin-top: px2vw(50);
  169. }
  170. .addStu-table {
  171. margin-top: px2vw(50);
  172. width: 100%;
  173. border: 1px solid #DDDDDD;
  174. border-collapse: collapse;
  175. background: #f9f9f9;
  176. }
  177. .addStu-input {
  178. // border: solid 1px #DDDDDD;
  179. width: 100%;
  180. height: 100%;
  181. }
  182. .addStu-addBox {
  183. width: 100%;
  184. margin-top: px2vw(20);
  185. }
  186. .addStu-addBtn {
  187. width: px2vw(158);
  188. height: px2vw(48);
  189. background: #EA252C;
  190. border-radius: px2vw(8);
  191. font-size: px2vw(18);
  192. color: #FFFFFF;
  193. line-height: px2vw(24);
  194. margin-top: px2vw(31);
  195. margin-bottom: px2vw(65);
  196. }
  197. .form-input {
  198. width: px2vw(355);
  199. height: px2vw(54);
  200. padding: px2vw(14) px2vw(20);
  201. font-size: px2vw(20);
  202. color: #070707;
  203. line-height: px2vw(26);
  204. background: #FFFFFF;
  205. border-radius: px2vw(4);
  206. border: 1px solid #B4B4B4;
  207. }
  208. .box2-table-box-left {
  209. // width: px2vw(1000);
  210. width: px2vw(500);
  211. }
  212. .box2-table-box-left-item {
  213. width: 100%;
  214. margin-top: px2vw(30);
  215. }
  216. .table-title {
  217. font-size: px2vw(22);
  218. color: #555555;
  219. line-height: px2vw(29);
  220. }
  221. .addStu-textarea {
  222. width: px2vw(800);
  223. height: px2vw(500);
  224. padding: px2vw(14) px2vw(20);
  225. font-size: px2vw(20);
  226. color: #070707;
  227. line-height: px2vw(26);
  228. background: #FFFFFF;
  229. border-radius: px2vw(4);
  230. border: 1px solid #B4B4B4;
  231. }
  232. .m_right {
  233. width: 100%;
  234. height: 100%;
  235. margin-top: 5rpx;
  236. padding: 0 150rpx;
  237. background-color: #fff;
  238. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  239. .m_right_hander {
  240. text-align: right;
  241. height: 250rpx;
  242. position: relative;
  243. .m_btn_red {
  244. position: absolute;
  245. height: 80rpx;
  246. line-height: 80rpx;
  247. padding: 0 40rpx;
  248. right: 0;
  249. top: 50%;
  250. transform: translateY(-50%);
  251. background: #EA252C;
  252. color: #fff;
  253. }
  254. }
  255. }
  256. tbody tr {
  257. border-top: 2rpx solid #DDDDDD !important;
  258. }
  259. tbody tr th {
  260. font-weight: 400 !important;
  261. height: 140rpx;
  262. line-height: 140rpx;
  263. }
  264. tbody tr:hover {
  265. // color: #fff;
  266. background: #FDEBEC;
  267. // opacity: 0.08;
  268. }
  269. .m-table-hander {
  270. background-color: #FFF8F7;
  271. height: 140rpx;
  272. line-height: 140rpx;
  273. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  274. font-weight: bold;
  275. }
  276. .m_edit {
  277. position: absolute;
  278. top: 50%;
  279. left: 50%;
  280. transform: translate(-50%, -50%);
  281. background: rgb(67, 127, 250);
  282. color: rgb(255, 255, 255);
  283. min-width: 130rpx;
  284. }
  285. .m_delete {
  286. position: absolute;
  287. top: 50%;
  288. left: 50%;
  289. min-width: 130rpx;
  290. transform: translate(-50%, -50%);
  291. background: rgb(234, 37, 44);
  292. color: rgb(255, 255, 255);
  293. }
  294. .m_right_footer {
  295. margin-top: 80rpx;
  296. margin-bottom: 80rpx;
  297. }
  298. .m_paging {
  299. text-align: right;
  300. .m_paging_item {
  301. padding: 10rpx 18rpx;
  302. border: 1rpx solid #DDDDDD;
  303. border-radius: 8rpx;
  304. margin-right: 10rpx;
  305. }
  306. .p_act {
  307. background: #EA252C;
  308. color: #fff;
  309. border: inherit;
  310. }
  311. }
  312. .m_paging_item:hover {
  313. background: #EA252C;
  314. color: #fff;
  315. border: inherit;
  316. }
  317. .m_act1 {
  318. color: #FF0019;
  319. }
  320. .m_right_container {
  321. // width: px2vw(1377);
  322. }
  323. .stu_box {
  324. width: px2vw(1377);
  325. }
  326. </style>