stuManage.vue 10 KB

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