bindingCardPage.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div class="bindingCardPage">
  3. <div class="title-box">
  4. <p>批量绑定校园卡</p>
  5. </div>
  6. <div class="watch-head-box">
  7. <p>姓名</p>
  8. <p>学号</p>
  9. <p>学院</p>
  10. <p>手机号码</p>
  11. <p>校园卡号</p>
  12. </div>
  13. <div class="center-max-big-box scrollbar-box">
  14. <div class="watch-data-list" v-for="(item,index) in watchList" :key="index">
  15. <p>{{item.nickName}}</p>
  16. <p>{{item.userName}}</p>
  17. <p>{{item.deptName}}</p>
  18. <p>{{item.phonenumber}}</p>
  19. <div class="input-big-box">
  20. <el-input class="input-box" type="text"
  21. maxLength="30"
  22. v-model="item.cardNum"
  23. clearable
  24. placeholder="请输入或读取校园卡号"
  25. />
  26. <p class="input-msg-p">{{item.cardType==1?'卡号已存在':(item.cardType==2?'卡号重复':'')}}</p>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="button-box">
  31. <p></p>
  32. <p class="reset-button-one" @click="outPageButton">返回</p>
  33. <p class="add-button-one-90" @click="setButton">保存</p>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import { studentBatchSelect, studentUpdateCardNum } from "@/api/system/user_student";
  39. export default {
  40. name: 'bindingCardPage',
  41. props:{
  42. ids:{},
  43. },
  44. data(){
  45. return{
  46. watchList:[],
  47. }
  48. },
  49. created(){
  50. },
  51. mounted(){
  52. this.studentBatchSelect();
  53. },
  54. methods:{
  55. //批量获取老师数据
  56. studentBatchSelect(){
  57. studentBatchSelect(this.ids).then(response => {
  58. this.watchList = response.data;
  59. this.getInitialization();
  60. })
  61. },
  62. //返回
  63. outPageButton(){
  64. this.$parent.outPage(1);
  65. },
  66. //提交
  67. setButton(){
  68. let self = this
  69. if(this.setVerification()){
  70. let list = [];
  71. for(let i=0;i<self.watchList.length;i++){
  72. if(self.watchList[i].cardNum){
  73. let obj = {
  74. userId:self.watchList[i].userId,
  75. cardNum:self.watchList[i].cardNum,
  76. }
  77. list.push(obj);
  78. }
  79. }
  80. studentUpdateCardNum(list).then(response => {
  81. if(response.data.repeatCard == 0){
  82. this.msgSuccess(response.msg);
  83. this.$parent.handleQuery();
  84. }else{
  85. this.repeatMark(response.data.repeatList);
  86. }
  87. })
  88. }
  89. },
  90. //提交验证
  91. setVerification(){
  92. let self = this;
  93. for(let i=0;i<self.watchList.length;i++){
  94. self.watchList[i].cardType = 0;
  95. }
  96. let num = 0;
  97. for(let i=0;i<self.watchList.length;i++){
  98. for(let o=0;o<self.watchList.length;o++){
  99. if(self.watchList[i].cardNum == self.watchList[o].cardNum &&
  100. self.watchList[i].userId != self.watchList[o].userId &&
  101. self.watchList[i].cardNum && self.watchList[o].cardNum){
  102. self.$set(self.watchList[i],'cardType',2);
  103. self.$set(self.watchList[o],'cardType',2);
  104. num++
  105. }
  106. }
  107. }
  108. this.$forceUpdate();
  109. return num == 0;
  110. },
  111. //数据初始化
  112. getInitialization(){
  113. let self = this;
  114. for(let i=0;i<self.watchList.length;i++){
  115. self.watchList[i].cardType = 0;
  116. }
  117. this.$forceUpdate();
  118. },
  119. //重复标记
  120. repeatMark(list){
  121. let self = this;
  122. for(let i=0;i<list.length;i++){
  123. for(let o=0;o<self.watchList.length;o++){
  124. if(list[i] == self.watchList[o].cardNum){
  125. self.watchList[o].cardType = 1;
  126. }
  127. }
  128. }
  129. this.$forceUpdate();
  130. },
  131. }
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. *{
  136. margin:0;
  137. padding:0;
  138. font-weight:500;
  139. color:#333;
  140. }
  141. .bindingCardPage{
  142. display: flex;
  143. flex-direction: column;
  144. flex:1;
  145. overflow: hidden;
  146. .title-box{
  147. border-bottom:1px solid #E0E0E0;
  148. p{
  149. color:#0045AF;
  150. line-height:60px;
  151. margin-left:24px;
  152. font-size:18px;
  153. }
  154. }
  155. .watch-head-box{
  156. padding:10px 40px 10px;
  157. display: flex;
  158. p{
  159. line-height:40px;
  160. font-size:16px;
  161. font-weight: 600;
  162. }
  163. p:nth-child(1){
  164. width:200px;
  165. }
  166. p:nth-child(2){
  167. width:200px;
  168. }
  169. p:nth-child(3){
  170. width:200px;
  171. }
  172. p:nth-child(4){
  173. width:300px;
  174. }
  175. input{
  176. width:300px;
  177. }
  178. }
  179. .center-max-big-box{
  180. flex:1;
  181. padding:0 40px;
  182. .watch-data-list{
  183. display: flex;
  184. margin-bottom:10px;
  185. p{
  186. line-height:40px;
  187. font-size:16px;
  188. }
  189. p:nth-child(1){
  190. width:200px;
  191. }
  192. p:nth-child(2){
  193. width:200px;
  194. }
  195. p:nth-child(3){
  196. width:200px;
  197. }
  198. p:nth-child(4){
  199. width:300px;
  200. }
  201. .input-big-box{
  202. display: flex;
  203. flex:1;
  204. .input-box{
  205. width:300px;
  206. }
  207. .input-msg-p{
  208. margin-left:20px;
  209. width:100px;
  210. color:#FF6666;
  211. font-size:14px;
  212. }
  213. }
  214. }
  215. }
  216. .button-box{
  217. height:80px;
  218. display: flex;
  219. border-top:1px solid #E0E0E0;
  220. p{
  221. margin-top:20px;
  222. }
  223. p:nth-child(1){
  224. flex:1;
  225. }
  226. p:nth-child(2){
  227. width:80px;
  228. margin-right:20px;
  229. font-size:16px;
  230. }
  231. p:nth-child(3){
  232. width:80px;
  233. margin-right:20px;
  234. font-size:16px;
  235. }
  236. }
  237. }
  238. </style>