addWorker.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="addWork">
  3. <NavBar/>
  4. <div class="addWork-container">
  5. <div class="search-flex">
  6. <van-search v-model="query.name" placeholder="请输入姓名" @clear="refreshData" @change="refreshData"/>
  7. </div>
  8. <div class="card-list">
  9. <Scroll
  10. ref="Scroll"
  11. @refresh="refreshData"
  12. @loadMore="getDataList"
  13. :pullup="pullup">
  14. <empty v-if="!dataList || dataList.length === 0" />
  15. <div v-else class="list-item">
  16. <van-cell
  17. :class="{'active':item.checked}"
  18. v-for="(item, index) in dataList"
  19. clickable
  20. :key="item.id"
  21. :title="item.name"
  22. :value="item.orgName"
  23. :label="item.phone || '无'"
  24. @click="click(item,index)">
  25. </van-cell>
  26. </div>
  27. </Scroll>
  28. </div>
  29. <div>
  30. <van-button :disabled="!selected" type="info" size="large" @click="onSubmit">确认授权</van-button>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import NavBar from '@/components/NavBar'
  37. import Scroll from '@/components/scroll/scroll'
  38. import {workerList,accredit} from './api'
  39. export default {
  40. components: {
  41. NavBar,
  42. Scroll,
  43. },
  44. data(){
  45. return {
  46. query:{
  47. name:'',
  48. orgId:null,
  49. checkSub:true,
  50. pageNum:1,
  51. pageSize:10
  52. },
  53. total:0,
  54. formData:{
  55. planId:null,
  56. beCheckedOrgId:null,
  57. taskId:null,
  58. ymdDate:null,
  59. userId:null,
  60. },
  61. dataList:[],
  62. ruleList:[],
  63. selected:null,
  64. prop:{
  65. label:'name',
  66. value:'id'
  67. },
  68. pullup:false,
  69. go:{
  70. type:'replace',
  71. path:'/securityDetail',
  72. }
  73. }
  74. },
  75. mounted(){
  76. console.log(this.$route,'this.$route')
  77. this.query.orgId = this.$route.query.orgId;
  78. this.formData.planId = this.$route.query.planId;
  79. this.formData.beCheckedOrgId = this.$route.query.beCheckedOrgId;
  80. this.formData.taskId = this.$route.query.taskId;
  81. this.formData.ymdDate = this.$route.query.ymdDate;
  82. this.getDataList();
  83. },
  84. methods:{
  85. onSubmit(){
  86. this.formData.userId = this.selected;
  87. accredit(this.formData).then(res=>{
  88. this.$toast('授权成功');
  89. this.$router.replace(
  90. {
  91. name:'securityCheckRegister',
  92. path:'/securityCheckRegister',
  93. params:{event:'refresh'}
  94. }
  95. );
  96. })
  97. },
  98. click(v,i){
  99. this.dataList.forEach(v=>v.checked = false);
  100. this.$set(this.dataList[i],'checked',!this.dataList[i].checked);
  101. this.selected = v.id;
  102. },
  103. refreshData(){
  104. this.pullup = true;
  105. this.total = 0;
  106. this.query.pageNum = 1;
  107. this.dataList = [];
  108. this.getDataList();
  109. },
  110. getDataList(){
  111. if( this.dataList.length !== 0 && this.dataList.length >= this.total) {
  112. this.pullup = false;
  113. this.$toast('已加载完毕');
  114. return;
  115. }
  116. workerList(this.query).then(data=>{
  117. let res = data.data;
  118. console.log(res,'resssssssss')
  119. if(res.total === '0'){
  120. this.pullup = false;
  121. this.$toast('已加载完毕');
  122. return
  123. }
  124. res.rows.forEach(v=>{
  125. v.checked = false;
  126. });
  127. this.total = res.total;
  128. if(this.dataList.length < res.total) {
  129. this.dataList = [...this.dataList,...res.rows] ;
  130. this.pullup = true;
  131. this.query.pageNum++;
  132. this.$refs.Scroll.refresh();
  133. }
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .addWork{
  141. .active{
  142. color:#1989fa;
  143. .van-cell__value{
  144. color:#1989fa;
  145. }
  146. }
  147. }
  148. </style>
  149. <style lang="scss" scoped>
  150. .addWork{
  151. .card-list{
  152. height: calc(100vh - 300px);
  153. overflow: auto;
  154. }
  155. .list-item{
  156. padding:20px;
  157. }
  158. .active{
  159. color:#1989fa;
  160. border-left: 5px solid #1989fa;
  161. }
  162. }
  163. </style>