stuManage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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="paging(i)">下一页</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:7,
  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.allStudent = res.data.Items;
  133. this.dataUsers_all = res.data.Students;
  134. this.pageTotalNum = Math.ceil(res.data.AllNumOfList/this.totalItem);
  135. console.log('this.pageTotalNum=',this.pageTotalNum)
  136. this.currentPage = i;
  137. this.showNextOrLastPageBtn();
  138. }
  139. //200失败
  140. else {
  141. console.log('suc200', res);
  142. }
  143. uni.hideLoading();
  144. },
  145. fail: (res) => {
  146. console.log("请求失败****");
  147. uni.hideLoading();
  148. }
  149. });
  150. },
  151. initPage() {
  152. this.paging(1);
  153. },
  154. onClick_last()
  155. {
  156. this.currentPage--;
  157. this.paging(this.currentPage);
  158. },
  159. onClick_next()
  160. {
  161. this.currentPage++;
  162. this.paging(this.currentPage);
  163. },
  164. showNextOrLastPageBtn()
  165. {
  166. if(this.pageTotalNum==this.currentPage)
  167. {
  168. this.bShowLastPageBtn = true;
  169. this.bShowNextPageBtn = false;
  170. }
  171. else if(1==this.currentPage)
  172. {
  173. this.bShowLastPageBtn = false;
  174. this.bShowNextPageBtn = true;
  175. }
  176. else
  177. {
  178. this.bShowLastPageBtn = true;
  179. this.bShowNextPageBtn = true;
  180. }
  181. if(this.pageTotalNum==1){
  182. this.bShowLastPageBtn = false;
  183. this.bShowNextPageBtn = false;
  184. }
  185. },
  186. onClick_addStudent() {
  187. this.isShowAdd = true;
  188. },
  189. // updateInfo() {
  190. // // this.index = 1;
  191. // this.allStudent = userController.studentList;
  192. // // console.log('this.allStudent=',this.allStudent)
  193. // // this.currentPage = Math.ceil(this.allStudent.length / 7);
  194. // this.updateTable();
  195. // // console.log("学生管理,更新页面", this.allStudent);
  196. // },
  197. // updateTable() {
  198. // this.curPageStudentList = [];
  199. // for (let i = 0; i < 7; i++) {
  200. // let student = this.allStudent[(this.currentPage - 1) * 7 + i];
  201. // if (student) {
  202. // let astudent = {
  203. // "userName": student.IlabAccount,
  204. // "name": student.Name,
  205. // "class": student.Class,
  206. // "progress": '',
  207. // "score": student.Scores.Score,
  208. // }
  209. // this.curPageStudentList.push(astudent);
  210. // }
  211. // }
  212. // // console.log("当前页学生列表", this.curPageStudentList);
  213. // },
  214. onClick_addStu_add() {
  215. // console.log(this.addStudentData);
  216. let self = this;
  217. MyRequest.AddUsers([this.addStudentData], function(res) {
  218. console.log("请求添加成功,返回值", res);
  219. if(res.data.Users[0].State == 2)
  220. {
  221. alert("该学生不存在");
  222. return;
  223. }
  224. // self.updateInfo();
  225. self.isShowAdd = false;
  226. self.addStudentData = {};
  227. userController.updateStudentList(self.updateInfo,null)
  228. }, null);
  229. },
  230. onClick_cancel(){
  231. this.isShowAdd = false;
  232. this.addStudentData = {};
  233. userController.updateStudentList(this.updateInfo,null)
  234. },
  235. onClick_XSSYQK(studentI){
  236. // console.log("实验情况studentI=",studentI);
  237. let UserID = this.allStudent[studentI].UserID;
  238. // console.log("UserID=",this.allStudent[studentI].UserID);
  239. this.$emit('onClick_XSSYQK',UserID);
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. .addStu-box {
  246. // margin-left: px2vw(100);
  247. margin-top: px2vw(50);
  248. }
  249. .addStu-table {
  250. margin-top: px2vw(50);
  251. width: 100%;
  252. border: 1px solid #DDDDDD;
  253. border-collapse: collapse;
  254. background: #f9f9f9;
  255. }
  256. .addStu-input {
  257. // border: solid 1px #DDDDDD;
  258. width: 100%;
  259. height: 100%;
  260. }
  261. .addStu-addBox {
  262. width: 100%;
  263. margin-top: px2vw(20);
  264. }
  265. .addStu-addBtn {
  266. width: px2vw(158);
  267. height: px2vw(48);
  268. background: #EA252C;
  269. border-radius: px2vw(8);
  270. font-size: px2vw(18);
  271. color: #FFFFFF;
  272. line-height: px2vw(24);
  273. margin-top: px2vw(31);
  274. margin-bottom: px2vw(65);
  275. }
  276. .form-input {
  277. width: px2vw(355);
  278. height: px2vw(54);
  279. padding: px2vw(14) px2vw(20);
  280. font-size: px2vw(20);
  281. color: #070707;
  282. line-height: px2vw(26);
  283. background: #FFFFFF;
  284. border-radius: px2vw(4);
  285. border: 1px solid #B4B4B4;
  286. }
  287. .box2-table-box-left {
  288. // width: px2vw(1000);
  289. width: px2vw(500);
  290. }
  291. .box2-table-box-left-item {
  292. width: 100%;
  293. margin-top: px2vw(30);
  294. }
  295. .table-title {
  296. font-size: px2vw(22);
  297. color: #555555;
  298. line-height: px2vw(29);
  299. }
  300. .addStu-textarea {
  301. width: px2vw(800);
  302. height: px2vw(500);
  303. padding: px2vw(14) px2vw(20);
  304. font-size: px2vw(20);
  305. color: #070707;
  306. line-height: px2vw(26);
  307. background: #FFFFFF;
  308. border-radius: px2vw(4);
  309. border: 1px solid #B4B4B4;
  310. }
  311. .m_right {
  312. width: 100%;
  313. height: 100%;
  314. margin-top: 5rpx;
  315. padding: 0 150rpx;
  316. background-color: #fff;
  317. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  318. .m_right_hander {
  319. text-align: right;
  320. height: 250rpx;
  321. position: relative;
  322. .m_btn_red {
  323. position: absolute;
  324. height: 80rpx;
  325. line-height: 80rpx;
  326. padding: 0 40rpx;
  327. right: 0;
  328. top: 50%;
  329. transform: translateY(-50%);
  330. background: #EA252C;
  331. color: #fff;
  332. }
  333. }
  334. }
  335. tbody tr {
  336. border-top: 2rpx solid #DDDDDD !important;
  337. }
  338. tbody tr th {
  339. font-weight: 400 !important;
  340. height: 140rpx;
  341. line-height: 140rpx;
  342. }
  343. // tbody tr:hover {
  344. // // color: #fff;
  345. // background: #FDEBEC;
  346. // // opacity: 0.08;
  347. // }
  348. .m-table-hander {
  349. background-color: #FFF8F7;
  350. height: 140rpx;
  351. line-height: 140rpx;
  352. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  353. font-weight: bold;
  354. }
  355. .m_edit {
  356. position: absolute;
  357. top: 50%;
  358. left: 50%;
  359. transform: translate(-50%, -50%);
  360. background: rgb(67, 127, 250);
  361. color: rgb(255, 255, 255);
  362. min-width: 130rpx;
  363. }
  364. .m_delete {
  365. position: absolute;
  366. top: 50%;
  367. left: 50%;
  368. min-width: 130rpx;
  369. transform: translate(-50%, -50%);
  370. background: rgb(234, 37, 44);
  371. color: rgb(255, 255, 255);
  372. }
  373. .m_right_footer {
  374. margin-top: 80rpx;
  375. margin-bottom: 80rpx;
  376. }
  377. .m_paging {
  378. text-align: right;
  379. .m_paging_item {
  380. padding: 10rpx 18rpx;
  381. border: 1rpx solid #DDDDDD;
  382. border-radius: 8rpx;
  383. margin-right: 10rpx;
  384. }
  385. .p_act {
  386. background: #EA252C;
  387. color: #fff;
  388. border: inherit;
  389. }
  390. }
  391. .m_paging_item:hover {
  392. background: #EA252C;
  393. color: #fff;
  394. border: inherit;
  395. }
  396. .m_act1 {
  397. color: #FF0019;
  398. }
  399. .m_right_container {
  400. // width: px2vw(1377);
  401. }
  402. .stu_box {
  403. width: px2vw(1377);
  404. }
  405. </style>