user.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <template>
  2. <view class="m_right">
  3. <view class="m_right_hander">
  4. <button size="mini" class="m_btn_red" @click="addUser()">添加用户</button>
  5. </view>
  6. <view class="m_right_container">
  7. <table style="width: 100%;border: 1px solid #DDDDDD;border-collapse: collapse">
  8. <thead class="m-table-hander">
  9. <tr>
  10. <!-- <th>用户名</th> -->
  11. <th>姓名</th>
  12. <th>班级</th>
  13. <th>学号</th>
  14. <th>电话</th>
  15. <th>ilab账户</th>
  16. <th>注册时间</th>
  17. <th>分数</th>
  18. <th>修改信息</th>
  19. <th>删除</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. <tr v-for="(dataUser,dataUserI) in dataUsers_all" :key="dataUserI">
  24. <!-- <th style="color: #EA252C;">{{dataUser.IlabAccount}}</th> -->
  25. <th>{{dataUser.Name}}</th>
  26. <th>{{dataUser.Class}}</th>
  27. <th>{{dataUser.StudentID}}</th>
  28. <th>{{dataUser.PhoneNum}}</th>
  29. <th>{{dataUser.IlabAccount}}</th>
  30. <th>{{dataUser.SignTime}}</th>
  31. <th>{{dataUser.TotalScore}}</th>
  32. <th class="btn_bg"><button type="default" size="mini" class="m_edit" @click="modify(dataUser)">修改</button></th>
  33. <th class="btn_bg"><button type="default" size="mini" class="m_delete" @click="deleteUser(dataUser)">删除</button></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="last()">上一页</text>
  41. <!-- <text class="m_paging_item" :key="i" v-for="i in pageTotalNum" @click="paging(i)" :class="i==index?'p_act':''"> -->
  42. <text class="m_paging_item" :key="i" v-for="i in pageTotalNum" @click="paging(i)" :class="i==currentPage?'p_act':''">
  43. {{i}}
  44. </text>
  45. <text class="m_paging_item m_paging_lower" v-show="bShowNextPageBtn" @click="next()">下一页</text>
  46. </view>
  47. </view>
  48. <popForm ref="popForm"></popForm>
  49. <popAlert ref="popAlert"></popAlert>
  50. </view>
  51. </template>
  52. <script>
  53. import popForm from '@/components/popForm.vue'
  54. import popAlert from '@/components/popAlert.vue'
  55. export default {
  56. name: "manager_user",
  57. components: {
  58. popForm,
  59. popAlert,
  60. },
  61. data() {
  62. return {
  63. pageTotalNum:1,
  64. currentPage:1,
  65. totalItem:2,
  66. dataUsers_all: [],
  67. bShowLastPageBtn:false,
  68. bShowNextPageBtn:false,
  69. }
  70. },
  71. methods: {
  72. paging(i) {
  73. // console.log('index=',i)
  74. uni.showLoading({
  75. title: '加载中'
  76. });
  77. let fromIndex = this.totalItem*(i-1);
  78. let toIndex = fromIndex+this.totalItem;
  79. let data = {
  80. "UserID": mydata_userInfo.userID,
  81. "BeginNum": fromIndex, //用户数组索引
  82. "EndNum": toIndex //用户数组索引结束
  83. }
  84. console.log('data===',data)
  85. uni.request({
  86. header: {
  87. 'Content-Type': 'application/json;charset=UTF-8'
  88. },
  89. url: mydata_api + '/backstage/getalluser',
  90. method: 'POST',
  91. data: data,
  92. dataType: 'json',
  93. success: (res) => {
  94. //100成功
  95. if (res.data.Code == 100) {
  96. console.log("请求全部用户res", res);
  97. this.dataUsers_all = res.data.Users;
  98. this.pageTotalNum = Math.ceil(res.data.AllNumOfList/this.totalItem);
  99. this.currentPage = i;
  100. this.showNextOrLastPageBtn();
  101. this.setTotalScore();
  102. }
  103. //200失败
  104. else {
  105. console.log('suc200', res);
  106. }
  107. uni.hideLoading();
  108. },
  109. fail: (res) => {
  110. console.log("请求失败****");
  111. uni.hideLoading();
  112. }
  113. });
  114. },
  115. initPage() {
  116. this.paging(1);
  117. },
  118. //分数合并
  119. setTotalScore() {
  120. for (let i = 0; i < this.dataUsers_all.length; i++) {
  121. let totalScore = 0;
  122. if(this.dataUsers_all[i].UserScore!="")
  123. {
  124. let UserScore = JSON.parse(this.dataUsers_all[i].UserScore);
  125. for (let j = 0; j < UserScore.length; j++) {
  126. let ascore = Number(UserScore[j].Score);
  127. console.log('ascore=',ascore)
  128. if (ascore!=-1) {
  129. totalScore += ascore;
  130. }
  131. }
  132. }
  133. this.dataUsers_all[i].TotalScore = totalScore;
  134. }
  135. },
  136. last()
  137. {
  138. this.currentPage--;
  139. this.paging(this.currentPage);
  140. },
  141. next()
  142. {
  143. this.currentPage++;
  144. this.paging(this.currentPage);
  145. },
  146. showNextOrLastPageBtn()
  147. {
  148. if(this.pageTotalNum==this.currentPage)
  149. {
  150. this.bShowLastPageBtn = true;
  151. this.bShowNextPageBtn = false;
  152. // console.log('11111')
  153. }
  154. else if(1==this.currentPage)
  155. {
  156. this.bShowLastPageBtn = false;
  157. this.bShowNextPageBtn = true;
  158. // console.log('2222')
  159. }
  160. else
  161. {
  162. this.bShowLastPageBtn = true;
  163. this.bShowNextPageBtn = true;
  164. // console.log('333333')
  165. }
  166. if(this.pageTotalNum==1){
  167. this.bShowLastPageBtn = false;
  168. this.bShowNextPageBtn = false;
  169. // console.log('444444')
  170. }
  171. },
  172. addUser(){
  173. this.$refs.popForm.isShow(true);
  174. this.$refs.popForm.setTitle('添加用户');
  175. let _self = this;
  176. let callback = function(content_arr){
  177. let data = {
  178. "UserID":mydata_userInfo.userID,
  179. "Users":[
  180. {
  181. "IlabAccount":content_arr[0].input,
  182. "Name":content_arr[1].input,
  183. "School":content_arr[2].input,
  184. "Department":content_arr[3].input,
  185. "Profession":content_arr[4].input,
  186. "Class":content_arr[5].input,
  187. "StudentID":Number(content_arr[6].input),
  188. "Post":content_arr[7].input,
  189. "PhoneNum":Number(content_arr[8].input),
  190. "Email":content_arr[9].input,
  191. "Nation":content_arr[10].input,
  192. "PoliticsStatus":content_arr[11].input,
  193. "NativePlace":content_arr[12].input,
  194. "Certificate":content_arr[13].input,
  195. "CertificateNum":content_arr[14].input,
  196. }
  197. ]
  198. }
  199. console.log('添加用户data===',data)
  200. uni.showLoading({
  201. title: '上传中'
  202. });
  203. uni.request({
  204. header: {
  205. 'Content-Type': 'application/json;charset=UTF-8'
  206. },
  207. url: mydata_api + '/backstage/addusers',
  208. method: 'POST',
  209. data: data,
  210. dataType: 'json',
  211. success: (res) => {
  212. //100成功
  213. if (res.data.Code == 100) {
  214. console.log("添加用户成功", res);
  215. _self.paging(_self.currentPage);
  216. }
  217. //200失败
  218. else {
  219. console.log('添加用户成功失败200', res);
  220. }
  221. uni.hideLoading();
  222. },
  223. fail: (res) => {
  224. console.log("添加用户成功失败");
  225. uni.hideLoading();
  226. }
  227. });
  228. };
  229. this.$refs.popForm.setContent([
  230. {
  231. 'name':'Ilab账号',
  232. 'input':'',
  233. 'type' :'text'
  234. },
  235. {
  236. 'name':'姓名',
  237. 'input':'',
  238. 'type' :'text'
  239. },
  240. {
  241. 'name':'学校',
  242. 'input':'',
  243. 'type' :'text'
  244. },
  245. {
  246. 'name':'院系',
  247. 'input':'',
  248. 'type' :'text'
  249. },
  250. {
  251. 'name':'专业',
  252. 'input':'',
  253. 'type' :'text'
  254. },
  255. {
  256. 'name':'班级',
  257. 'input':'',
  258. 'type' :'text'
  259. },
  260. {
  261. 'name':'学号',
  262. 'input':'',
  263. 'type' :'text'
  264. },
  265. {
  266. 'name':'职务',
  267. 'input':'',
  268. 'type' :'text'
  269. },
  270. {
  271. 'name':'电话',
  272. 'input':'',
  273. 'type' :'text'
  274. },
  275. {
  276. 'name':'邮箱',
  277. 'input':'',
  278. 'type' :'text'
  279. },
  280. {
  281. 'name':'民族',
  282. 'input':'',
  283. 'type' :'text'
  284. },
  285. {
  286. 'name':'政治面貌',
  287. 'input':'',
  288. 'type' :'text'
  289. },
  290. {
  291. 'name':'籍贯',
  292. 'input':'',
  293. 'type' :'text'
  294. },
  295. {
  296. 'name':'证件类型',
  297. 'input':'',
  298. 'type' :'text'
  299. },
  300. {
  301. 'name':'证件号码',
  302. 'input':'',
  303. 'type' :'text'
  304. }
  305. ],callback);
  306. // this.$refs.popForm.setContent([
  307. // {
  308. // 'name':'Ilab账号',
  309. // 'input':'',
  310. // 'type' :'text'
  311. // },
  312. // {
  313. // 'name':'设置用户',
  314. // 'input':mydata_userInfo.userID,
  315. // 'type' :'text'
  316. // },
  317. // {
  318. // 'name':'被设置用户ID',
  319. // 'input':'',
  320. // 'type' :'text'
  321. // },
  322. // {
  323. // 'name':'姓名',
  324. // 'input':'',
  325. // 'type' :'text'
  326. // },
  327. // {
  328. // 'name':'学校',
  329. // 'input':'',
  330. // 'type' :'text'
  331. // },
  332. // {
  333. // 'name':'院系',
  334. // 'input':'',
  335. // 'type' :'text'
  336. // },
  337. // {
  338. // 'name':'专业',
  339. // 'input':'',
  340. // 'type' :'text'
  341. // },
  342. // {
  343. // 'name':'班级',
  344. // 'input':'',
  345. // 'type' :'text'
  346. // },
  347. // {
  348. // 'name':'学号',
  349. // 'input':'',
  350. // 'type' :'text'
  351. // },
  352. // {
  353. // 'name':'Post',
  354. // 'input':'',
  355. // 'type' :'text'
  356. // },
  357. // {
  358. // 'name':'职务',
  359. // 'input':'',
  360. // 'type' :'text'
  361. // },
  362. // {
  363. // 'name':'电话',
  364. // 'input':'',
  365. // 'type' :'text'
  366. // },
  367. // {
  368. // 'name':'邮箱',
  369. // 'input':'',
  370. // 'type' :'text'
  371. // },
  372. // {
  373. // 'name':'民族',
  374. // 'input':'',
  375. // 'type' :'text'
  376. // },
  377. // {
  378. // 'name':'政治面貌',
  379. // 'input':'',
  380. // 'type' :'text'
  381. // },
  382. // {
  383. // 'name':'籍贯',
  384. // 'input':'',
  385. // 'type' :'text'
  386. // },
  387. // {
  388. // 'name':'证件类型',
  389. // 'input':'',
  390. // 'type' :'text'
  391. // },
  392. // {
  393. // 'name':'证件号码',
  394. // 'input':'',
  395. // 'type' :'text'
  396. // }
  397. // ],callback);
  398. },
  399. modify(dataUser)
  400. {
  401. this.$refs.popForm.isShow(true);
  402. this.$refs.popForm.setTitle('修改用户信息');
  403. let _self = this;
  404. let callback = function(content_arr){
  405. let data = {
  406. "UserID":mydata_userInfo.userID,
  407. "SetUserID" : dataUser.Id,
  408. "Name":content_arr[0].input,
  409. "School":dataUser.School,
  410. "Department":dataUser.Department,
  411. "Profession":dataUser.Profession,
  412. "Class":content_arr[1].input,
  413. "StudentID":Number(content_arr[2].input),
  414. "Post":dataUser.Post,
  415. "PhoneNum":Number(content_arr[3].input),
  416. "Email":dataUser.Email,
  417. "Nation":dataUser.Nation,
  418. "PoliticsStatus":dataUser.PoliticsStatus,
  419. "NativePlace":dataUser.NativePlace,
  420. "Certificate":dataUser.Certificate,
  421. "CertificateNum":dataUser.CertificateNum,
  422. }
  423. // console.log('data=',data)
  424. uni.showLoading({
  425. title: '上传中'
  426. });
  427. uni.request({
  428. header: {
  429. 'Content-Type': 'application/json;charset=UTF-8'
  430. },
  431. url: mydata_api + '/user/setuserinfo',
  432. method: 'POST',
  433. data: data,
  434. dataType: 'json',
  435. success: (res) => {
  436. //100成功
  437. if (res.data.Code == 100) {
  438. console.log("修改用户信息成功", res);
  439. _self.paging(_self.currentPage);
  440. }
  441. //200失败
  442. else {
  443. console.log('修改用户信息失败200', res);
  444. }
  445. uni.hideLoading();
  446. },
  447. fail: (res) => {
  448. console.log("修改用户信息失败");
  449. uni.hideLoading();
  450. }
  451. });
  452. };
  453. this.$refs.popForm.setContent([
  454. {
  455. 'name':'姓名',
  456. 'input':dataUser.Name,
  457. 'type' :'text'
  458. },
  459. {
  460. 'name':'班级',
  461. 'input':dataUser.Class,
  462. 'type' :'text'
  463. },
  464. {
  465. 'name':'学号',
  466. 'input':dataUser.StudentID,
  467. 'type' :'text'
  468. },
  469. {
  470. 'name':'电话',
  471. 'input':dataUser.PhoneNum,
  472. 'type' :'text'
  473. }
  474. ],callback);
  475. },
  476. deleteUser(dataUser)
  477. {
  478. this.$refs.popAlert.isShow(true);
  479. this.$refs.popAlert.setTitle('提示');
  480. let _self = this;
  481. let callback = function(){
  482. let data = {
  483. "UserID":mydata_userInfo.userID,
  484. "DeleteUserID" : dataUser.Id
  485. }
  486. console.log('data=',data)
  487. uni.showLoading({
  488. title: '上传中'
  489. });
  490. uni.request({
  491. header: {
  492. 'Content-Type': 'application/json;charset=UTF-8'
  493. },
  494. url: mydata_api + '/backstage/deleteuser',
  495. method: 'POST',
  496. data: data,
  497. dataType: 'json',
  498. success: (res) => {
  499. //100成功
  500. if (res.data.Code == 100) {
  501. console.log("删除用户成功", res);
  502. _self.paging(_self.currentPage);
  503. }
  504. //200失败
  505. else {
  506. console.log('删除用户失败200', res);
  507. }
  508. uni.hideLoading();
  509. },
  510. fail: (res) => {
  511. console.log("删除用户失败");
  512. uni.hideLoading();
  513. }
  514. });
  515. }
  516. this.$refs.popAlert.setContent('是否删除用户',callback);
  517. },
  518. }
  519. }
  520. </script>
  521. <style lang="scss">
  522. // 允许文字被选择
  523. th
  524. {
  525. moz-user-select: -moz-text;
  526. -moz-user-select: text;
  527. -o-user-select: text;
  528. -khtml-user-select: text;
  529. -webkit-user-select: text;
  530. -ms-user-select: text;
  531. user-select: text;
  532. }
  533. .m_right {
  534. width: 100%;
  535. margin-top: 5rpx;
  536. padding: 0 150rpx;
  537. background-color: #fff;
  538. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  539. .m_right_hander {
  540. text-align: right;
  541. height: 250rpx;
  542. position: relative;
  543. .m_btn_red {
  544. position: absolute;
  545. height: 80rpx;
  546. line-height: 80rpx;
  547. padding: 0 40rpx;
  548. right: 0;
  549. top: 50%;
  550. transform: translateY(-50%);
  551. background: #EA252C;
  552. color: #fff;
  553. }
  554. }
  555. }
  556. tbody tr {
  557. // border-top: 2rpx solid #DDDDDD !important;
  558. border: 2rpx solid #DDDDDD !important;
  559. }
  560. th {
  561. border: 2rpx solid #DDDDDD !important;
  562. }
  563. tbody tr th {
  564. font-weight: 400 !important;
  565. height: 140rpx;
  566. line-height: 140rpx;
  567. border: 2rpx solid #DDDDDD !important;
  568. }
  569. // tbody tr:hover {
  570. // // color: #fff;
  571. // background: #FDEBEC;
  572. // // opacity: 0.08;
  573. // }
  574. .center{
  575. display: flex;
  576. justify-content: center;
  577. align-items: center;
  578. }
  579. .m-table-hander {
  580. background-color: #FFF8F7;
  581. height: 140rpx;
  582. line-height: 140rpx;
  583. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  584. font-weight: bold;
  585. }
  586. .btn_bg{
  587. // border: 1rpx solid #DDDDDD;
  588. // display: flex;
  589. // justify-content: center;
  590. // align-items: center;
  591. }
  592. .m_edit {
  593. // position: relative;
  594. // top: 50%;
  595. // left: 50%;
  596. // transform: translate(-50%, -50%);
  597. background: rgb(67, 127, 250);
  598. color: rgb(255, 255, 255);
  599. // width: 60%;
  600. }
  601. .m_delete {
  602. background: rgb(234, 37, 44);
  603. color: rgb(255, 255, 255);
  604. // width: 60%;
  605. }
  606. .m_right_footer {
  607. margin-top: 80rpx;
  608. }
  609. .m_paging {
  610. text-align: right;
  611. .m_paging_item {
  612. padding: 10rpx 18rpx;
  613. border: 1rpx solid #DDDDDD;
  614. border-radius: 8rpx;
  615. margin-right: 10rpx;
  616. }
  617. .p_act {
  618. background: #EA252C;
  619. color: #fff;
  620. border: inherit;
  621. }
  622. }
  623. .m_paging_item:hover {
  624. background: #EA252C;
  625. color: #fff;
  626. border: inherit;
  627. }
  628. .m_act1 {
  629. color: #FF0019;
  630. }
  631. </style>