bindingCardPage.vue 5.6 KB

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