stuManage.vue 9.9 KB

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