item.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.examine=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. let msgData={
  89. openId:item.openId,
  90. content:"审核已通过",
  91. remarks:"已审核",
  92. enterpriseName:item.enterpriseName
  93. }
  94. that.send(msgData)
  95. that.mescroll.resetUpScroll()
  96. }
  97. })
  98. })
  99. },
  100. /**
  101. * 显示审核不通过的意见框
  102. * @param {Object} item
  103. */
  104. fail(item){
  105. this.$emit('showOpinion',item)
  106. },
  107. async send(msgData){
  108. let tokenData={
  109. grantType:this.$api.wxData.subscribe_grant_type,
  110. appId:this.$api.wxData.appId,
  111. secret:this.$api.wxData.secret
  112. }
  113. let res=await this.$api.wxApi.getAccessToken(tokenData)
  114. let token=JSON.parse(res.data).access_token
  115. let subscribeData={
  116. accessToken:token,
  117. touser:msgData.openId,
  118. lang:"zh_CN",
  119. page:'/pages/index/index',
  120. miniprogramState:this.$miniprogramState.FORMAL,
  121. templateId: this.$tmplIds[0],
  122. "data": {
  123. "thing13": {
  124. "value": msgData.enterpriseName
  125. },
  126. "thing9":{
  127. "value": "员工认证信息审核"
  128. },
  129. "phrase2": {
  130. "value": msgData.content
  131. },
  132. "thing3": {
  133. "value": msgData.remarks
  134. },
  135. }
  136. }
  137. this.$api.wxApi.subscribe(subscribeData).then(res=>{
  138. console.log(res);
  139. }).catch(err=>{
  140. console.error(err);
  141. })
  142. },
  143. /**
  144. * @param {Object} mescroll 初始化组件
  145. */
  146. initMeScroll(mescroll) {
  147. this.mescroll = mescroll
  148. },
  149. /**
  150. * @param {Object} mescroll 上拉回调
  151. */
  152. upFn(mescroll) {
  153. let that=this
  154. let obj={
  155. realName:this.realName,
  156. phone:this.phone,
  157. current:mescroll.num,
  158. size:mescroll.size
  159. }
  160. if (this.loginType==this.$loginType.ENTERPRISE) {
  161. //企业登录
  162. obj.enterpriseId=this.enterpriseId
  163. }else if(this.loginType==this.$loginType.AGENCY){
  164. //园区管理员登陆
  165. obj.agencyId=this.agencyId
  166. }
  167. if (this.item.value!=-1) {
  168. //不是查询全部就传examine
  169. obj.examine=this.item.value
  170. }
  171. try{
  172. this.$api.enterprisestaff.page(obj).then(res=>{
  173. let data=res.data.records
  174. let length=data.length
  175. let total=res.data.total
  176. mescroll.endBySize(length, total);
  177. if(mescroll.num == 1) that.list = []; //如果是第一页需手动制空列表
  178. that.list=that.list.concat(data); //追加新数据
  179. })
  180. }catch(e){
  181. mescroll.endErr();
  182. }
  183. },
  184. /**
  185. * 下拉回调
  186. * */
  187. downFn(mescroll) {
  188. setTimeout(()=>{
  189. this.$showToast('刷新成功')
  190. this.mescroll.resetUpScroll()
  191. },1500)
  192. },
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. view{
  198. box-sizing: border-box;
  199. }
  200. </style>