item.vue 4.9 KB

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