item.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <u-toast ref="uToast"/>
  4. <card @pass="pass" @fail="fail" :list="list" ></card>
  5. </MeScroll>
  6. </template>
  7. <script>
  8. import MeScroll from '@/components/mescroll-body/mescroll-uni.vue'
  9. import card from './card.vue'
  10. var app=getApp()
  11. export default {
  12. components:{
  13. MeScroll,card
  14. },
  15. props: {
  16. //审核意见
  17. opinion:String,
  18. //真实姓名
  19. realName:String,
  20. //联系方式
  21. phone:String,
  22. type: Number,
  23. i: Number,
  24. fireType: Number,
  25. item:Object
  26. },
  27. data() {
  28. return {
  29. //审核不通过时展示
  30. modelShow:false,
  31. //审核不通过的原因
  32. dataDetail:{},
  33. //所属公司
  34. enterpriseId:'',
  35. //登录类型
  36. loginType:'',
  37. //园区id
  38. agencyId:'',
  39. isInit: false, // 是否初始化
  40. list: [], // 列表数据
  41. mescroll: null, // mescroll 对象
  42. // 上拉配置参数
  43. up: {
  44. noMoreSize: 2,
  45. auto: false,
  46. page: {
  47. page: 0,
  48. size: 10
  49. }
  50. },
  51. // 下拉配置参数
  52. down: {
  53. use: false,
  54. auto: false
  55. }
  56. }
  57. },
  58. created() {
  59. this.enterpriseId= this.$cache.get('enterpriseId')
  60. this.loginType=this.$cache.get('loginType')
  61. this.agencyId=this.$cache.get('agencyId')
  62. },
  63. watch:{
  64. type(val) {
  65. if(!this.isInit && val === this.i) {
  66. this.mescroll.resetUpScroll()
  67. }
  68. }
  69. },
  70. mounted() {
  71. if(!this.isInit && this.i === 0) {
  72. this.mescroll.resetUpScroll()
  73. }
  74. },
  75. methods: {
  76. /**
  77. * 通过审核
  78. */
  79. pass(data){
  80. let that=this
  81. let item=this.$u.deepClone(data)
  82. this.$showModel("确定审核通过该员工信息吗?").then(res=>{
  83. item.auditStatus=1
  84. item.auditTime=this.$createDateTime()
  85. this.$api.enterprisestaff.submit(item).then(res=>{
  86. if (res.success==true) {
  87. this.$showToast(res.msg)
  88. that.send(item)
  89. that.mescroll.resetUpScroll()
  90. }
  91. })
  92. })
  93. },
  94. /**
  95. * 显示审核不通过的意见框
  96. * @param {Object} item
  97. */
  98. fail(item){
  99. this.$emit('showOpinion',item)
  100. },
  101. async send(item){
  102. let tokenData={
  103. grantType:this.$api.wxData.subscribe_grant_type,
  104. appId:this.$api.wxData.appId,
  105. secret:this.$api.wxData.secret
  106. }
  107. let res=await this.$api.wxApi.getAccessToken(tokenData)
  108. let token=JSON.parse(res.data).access_token
  109. let subscribeData={
  110. accessToken:token,
  111. touser:item.openId,
  112. lang:"zh_CN",
  113. page:'/pages/login/login',
  114. miniprogramState:this.$miniprogramState,
  115. templateId: this.$staffTmplIds[0],
  116. "data": {
  117. "name1": {
  118. "value": this.$cache.get('loginAccount')
  119. },
  120. "phrase5":{
  121. "value": "员工认证"
  122. },
  123. "phrase2": {
  124. "value": "审核已通过"
  125. },
  126. "thing3": {
  127. "value": '已审核'
  128. },
  129. }
  130. }
  131. this.$api.wxApi.subscribe(subscribeData).then(res=>{
  132. console.log(res);
  133. }).catch(err=>{
  134. console.error(err);
  135. })
  136. },
  137. /**
  138. * @param {Object} mescroll 初始化组件
  139. */
  140. initMeScroll(mescroll) {
  141. this.mescroll = mescroll
  142. },
  143. /**
  144. * @param {Object} mescroll 上拉回调
  145. */
  146. upFn(mescroll) {
  147. let that=this
  148. let obj={
  149. realName:this.realName,
  150. phone:this.phone,
  151. current:mescroll.num,
  152. size:mescroll.size
  153. }
  154. if (this.loginType==this.$loginType.ENTERPRISE) {
  155. //企业登录
  156. obj.enterpriseId=this.enterpriseId
  157. }else if(this.loginType==this.$loginType.AGENCY){
  158. //园区管理员登陆
  159. obj.agencyId=this.agencyId
  160. }
  161. if (this.item.value!=-1) {
  162. //不是查询全部就传examine
  163. obj.auditStatus=this.item.value
  164. }
  165. try{
  166. this.$api.enterprisestaff.page(obj).then(res=>{
  167. let data=res.data.records
  168. let length=data.length
  169. let total=res.data.total
  170. mescroll.endBySize(length, total);
  171. if(mescroll.num == 1) that.list = []; //如果是第一页需手动制空列表
  172. that.list=that.list.concat(data); //追加新数据
  173. })
  174. }catch(e){
  175. mescroll.endErr();
  176. }
  177. },
  178. /**
  179. * 下拉回调
  180. * */
  181. downFn(mescroll) {
  182. setTimeout(()=>{
  183. this.$showToast('刷新成功')
  184. this.mescroll.resetUpScroll()
  185. },1500)
  186. },
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. view{
  192. box-sizing: border-box;
  193. }
  194. </style>