list.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view>
  3. <van-sticky>
  4. <view class="top-wrap">
  5. <view @click="handleGoSearch">
  6. <van-search disabled use-left-icon-slot shape="round" placeholder="客户名称/社会信用码">
  7. <view slot="left-icon">
  8. <image src="../static/search-icon.png" mode="aspectFill" class="search-icon"></image>
  9. </view>
  10. </van-search>
  11. </view>
  12. <van-tabs id="tabs" :active="status" title-active-color="#3385FF" color="#3385FF" @change="typeChange">
  13. <van-tab :title="item" :name="item" v-for="item in tabList" :key="item"></van-tab>
  14. </van-tabs>
  15. </view>
  16. </van-sticky>
  17. <van-empty description="暂无数据" :image="require('@/static/empty.png')" v-if="finished&&list.length===0"/>
  18. <view class="list" v-else>
  19. <approve-list-item v-for="item in list" :key="item.id" :data="item"></approve-list-item>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {apiContractApproveList,apiContractList} from '@/api/approve/contract.js'
  25. import approveListItem from '../components/approveListItem.vue'
  26. export default{
  27. components:{
  28. approveListItem
  29. },
  30. data() {
  31. return {
  32. tabList:[],
  33. status: '待审批',
  34. list:[],
  35. page:1,
  36. finished:false,
  37. }
  38. },
  39. onLoad() {
  40. this.initTabs()//初始化tab 栏
  41. if(this.status==='待提交'){
  42. this.getContractList()
  43. }else{
  44. this.getList()
  45. }
  46. // 更新列表
  47. uni.$on('contractApproveListUpdate',(e)=>{
  48. console.log('更新列表');
  49. this.list=this.list.filter(item=>{
  50. return !(item.ContractApprovalId==e.ContractApprovalId&&item.ContractApprovalRecordId==e.ContractApprovalRecordId&&item.ContractId==e.ContractId)
  51. })
  52. })
  53. },
  54. onUnload(){
  55. uni.$off('contractApproveListUpdate')
  56. },
  57. onShow() {
  58. this.$nextTick(()=>{
  59. this.selectComponent('#tabs').resize();// 解决初始渲染 vant tab 底部条
  60. })
  61. // this.page=1
  62. // this.list=[]
  63. // if(this.status==='待提交'){
  64. // this.getContractList()
  65. // }else{
  66. // this.getList()
  67. // }
  68. },
  69. onPullDownRefresh() {
  70. this.page=1
  71. this.finished=false
  72. this.list=[]
  73. if(this.status==='待提交'){
  74. this.getContractList()
  75. }else{
  76. this.getList()
  77. }
  78. setTimeout(()=>{
  79. uni.stopPullDownRefresh()
  80. },1500)
  81. },
  82. onReachBottom() {
  83. if(this.finished) return
  84. this.page++
  85. if(this.status==='待提交'){
  86. this.getContractList()
  87. }else{
  88. this.getList()
  89. }
  90. },
  91. methods: {
  92. //初始化tab
  93. initTabs(){
  94. // ficc销售 权益销售
  95. const RoleTypeCode=this.$store.state.userInfo.RoleTypeCode
  96. if(RoleTypeCode==='ficc_seller'||RoleTypeCode==='rai_seller'||RoleTypeCode==='ficc_group'||RoleTypeCode==='rai_group'){
  97. this.tabList=['待审批','处理中','已审批','已签回','待提交','已撤回','已作废']
  98. this.status='待审批'
  99. }
  100. // ficc管理员 权益管理员 合规compliance
  101. if(RoleTypeCode==='ficc_admin'||RoleTypeCode==='rai_admin'||RoleTypeCode==='compliance'||RoleTypeCode==='admin'){
  102. this.tabList=['待审批','处理中','已审批','已签回','已作废']
  103. this.status='待审批'
  104. }
  105. },
  106. // 去搜索
  107. handleGoSearch() {
  108. uni.navigateTo({
  109. url: '../search/index?type=contract'
  110. })
  111. },
  112. typeChange(e){
  113. this.status=e.detail.name
  114. this.page=1
  115. this.finished=false
  116. this.list=[]
  117. if(this.status==='待提交'){
  118. this.getContractList()
  119. }else{
  120. this.getList()
  121. }
  122. },
  123. //获取列表数据
  124. async getList(){
  125. const res=await apiContractApproveList({
  126. CurrentIndex:this.page,
  127. Status:this.status,
  128. Keyword:''
  129. })
  130. if(res.code===200){
  131. if(!res.data.List||res.data.List.length===0){
  132. this.finished=true
  133. }else{
  134. if(this.page===1&&res.data.List.length<20){
  135. this.finished=true
  136. }
  137. let arr=res.data.List.map(item=>{
  138. let backTime=''
  139. if(item.Status==='已撤回'){
  140. backTime=item.ModifyTime
  141. }
  142. return {
  143. title:item.CompanyName,
  144. saller:item.SellerName,
  145. submitTime:this.status==='处理中'?item.ModifyTime:item.CreateTime,
  146. approveTime:item.ApproveTime,
  147. checkBackTime:item.CheckBackFileTime,
  148. backTime:backTime,
  149. cancelTime:item.InvalidTime,
  150. status:item.Status,
  151. applyType:item.ApplyContent,
  152. id:item.ContractApprovalId,
  153. ContractApprovalId:item.ContractApprovalId,
  154. ContractApprovalRecordId:item.ContractApprovalRecordId,
  155. ContractId:item.ContractId,
  156. type:'contract',
  157. }
  158. })
  159. this.list=[...this.list,...arr]
  160. }
  161. }
  162. },
  163. // 获取合同列表
  164. async getContractList(){
  165. const res=await apiContractList({
  166. CurrentIndex:this.page,
  167. Status:this.status,
  168. Keyword:''
  169. })
  170. if(res.code===200){
  171. if(res.data.Paging.IsEnd){
  172. this.finished=true
  173. }
  174. let arr=res.data.List.map(item=>{
  175. let backTime=''
  176. if(item.Status==='已撤回'){
  177. backTime=item.ModifyTime
  178. }
  179. return {
  180. title:item.CompanyName,
  181. saller:item.SellerName,
  182. submitTime:item.CreateTime,
  183. approveTime:item.ApproveTime,
  184. checkBackTime:item.CheckBackFileTime,
  185. backTime:backTime,
  186. cancelTime:item.InvalidTime,
  187. status:item.Status,
  188. applyType:'生成新模板',
  189. id:item.ContractId,
  190. ContractApprovalId:0,
  191. ContractApprovalRecordId:0,
  192. ContractId:item.ContractId,
  193. ModifyTime:item.ModifyTime,
  194. type:'contract',
  195. }
  196. })
  197. this.list=[...this.list,...arr]
  198. }
  199. }
  200. },
  201. }
  202. </script>
  203. <style lang="scss">
  204. .search-icon {
  205. width: 40rpx;
  206. height: 40rpx;
  207. display: block;
  208. position: relative;
  209. top: 4rpx;
  210. margin-right: 10rpx;
  211. }
  212. .list{
  213. padding: 20rpx;
  214. }
  215. </style>