stuManage.vue 9.5 KB

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