bindingCardPage.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. if (self.watchList[i].cardNum){
  96. self.watchList[i].cardNum = self.watchList[i].cardNum.replace(/^\s*|\s*$/g,"");
  97. }
  98. }
  99. let num = 0;
  100. for(let i=0;i<self.watchList.length;i++){
  101. for(let o=0;o<self.watchList.length;o++){
  102. if(self.watchList[i].cardNum == self.watchList[o].cardNum &&
  103. self.watchList[i].userId != self.watchList[o].userId &&
  104. self.watchList[i].cardNum && self.watchList[o].cardNum){
  105. self.$set(self.watchList[i],'cardType',2);
  106. self.$set(self.watchList[o],'cardType',2);
  107. num++
  108. }
  109. }
  110. }
  111. this.$forceUpdate();
  112. return num == 0;
  113. },
  114. //数据初始化
  115. getInitialization(){
  116. let self = this;
  117. for(let i=0;i<self.watchList.length;i++){
  118. self.watchList[i].cardType = 0;
  119. }
  120. this.$forceUpdate();
  121. },
  122. //重复标记
  123. repeatMark(list){
  124. let self = this;
  125. for(let i=0;i<list.length;i++){
  126. for(let o=0;o<self.watchList.length;o++){
  127. if(list[i] == self.watchList[o].cardNum){
  128. self.watchList[o].cardType = 1;
  129. }
  130. }
  131. }
  132. this.$forceUpdate();
  133. },
  134. }
  135. }
  136. </script>
  137. <style scoped lang="scss">
  138. *{
  139. margin:0;
  140. padding:0;
  141. font-weight:500;
  142. color:#333;
  143. }
  144. .bindingCardPage{
  145. display: flex;
  146. flex-direction: column;
  147. flex:1;
  148. overflow: hidden;
  149. .title-box{
  150. border-bottom:1px solid #E0E0E0;
  151. p{
  152. color:#0045AF;
  153. line-height:60px;
  154. margin-left:24px;
  155. font-size:18px;
  156. }
  157. }
  158. .watch-head-box{
  159. padding:10px 40px 10px;
  160. display: flex;
  161. p{
  162. line-height:40px;
  163. font-size:16px;
  164. font-weight: 600;
  165. }
  166. p:nth-child(1){
  167. width:200px;
  168. }
  169. p:nth-child(2){
  170. width:200px;
  171. }
  172. p:nth-child(3){
  173. width:200px;
  174. }
  175. p:nth-child(4){
  176. width:300px;
  177. }
  178. input{
  179. width:300px;
  180. }
  181. }
  182. .center-max-big-box{
  183. flex:1;
  184. padding:0 40px;
  185. .watch-data-list{
  186. display: flex;
  187. margin-bottom:10px;
  188. p{
  189. line-height:40px;
  190. font-size:16px;
  191. }
  192. p:nth-child(1){
  193. width:200px;
  194. }
  195. p:nth-child(2){
  196. width:200px;
  197. }
  198. p:nth-child(3){
  199. width:200px;
  200. }
  201. p:nth-child(4){
  202. width:300px;
  203. }
  204. .input-big-box{
  205. display: flex;
  206. flex:1;
  207. .input-box{
  208. width:300px;
  209. }
  210. .input-msg-p{
  211. margin-left:20px;
  212. width:100px;
  213. color:#FF6666;
  214. font-size:14px;
  215. }
  216. }
  217. }
  218. }
  219. .button-box{
  220. height:80px;
  221. display: flex;
  222. border-top:1px solid #E0E0E0;
  223. p{
  224. margin-top:20px;
  225. }
  226. p:nth-child(1){
  227. flex:1;
  228. }
  229. p:nth-child(2){
  230. width:80px;
  231. margin-right:20px;
  232. font-size:16px;
  233. }
  234. p:nth-child(3){
  235. width:80px;
  236. margin-right:20px;
  237. font-size:16px;
  238. }
  239. }
  240. }
  241. </style>