item.vue 4.8 KB

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