index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view v-if="!refreshPage" class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar
  6. v-if="type || !showTabbar"
  7. :title="navList[navIndex].label">
  8. <button
  9. v-if="activeCom === 'CustomerList'"
  10. class="button white-btn"
  11. @click="handleToStatic">
  12. <text class="ft ft-statistics" />
  13. </button>
  14. <!-- #ifndef MP-WEIXIN -->
  15. <button class="button white-btn" @click="handleCrmSearch">
  16. <text class="wk wk-search" />
  17. </button>
  18. <!-- #endif -->
  19. </wk-nav-bar>
  20. <list-tab-header
  21. v-else
  22. v-model="navIndex"
  23. :nav-list="navList"
  24. :placeholder="placeholderText"
  25. @search="handleCrmSearch">
  26. <button
  27. v-if="activeCom === 'CustomerList'"
  28. class="button white-btn"
  29. @click="handleToStatic">
  30. <text class="ft ft-statistics" />
  31. </button>
  32. </list-tab-header>
  33. <!-- #ifdef MP-WEIXIN -->
  34. <view v-if="type" class="search-box linear-gradient">
  35. <view class="box" @click="handleCrmSearch">
  36. <text class="wk wk-search" />
  37. <text class="wk-placeholder">
  38. {{ placeholderText }}
  39. </text>
  40. </view>
  41. </view>
  42. <!-- #endif -->
  43. <view class="list-view">
  44. <!-- #ifdef MP-WEIXIN -->
  45. <customer-list v-if="activeCom === 'CustomerList'" />
  46. <contacts-list v-else-if="activeCom === 'ContactsList'" />
  47. <!-- #endif -->
  48. <!-- #ifndef MP-WEIXIN -->
  49. <components :is="activeCom" />
  50. <!-- #endif -->
  51. </view>
  52. </view>
  53. <wk-tabbar
  54. v-if="!type && showTabbar"
  55. v-model="footerIndex"
  56. :list="mixinFooterNav" />
  57. </view>
  58. </template>
  59. <script>
  60. import ListTabHeader from '@/components/base/list-tab-header.vue'
  61. import CustomerList from './customerList.vue'
  62. import ContactsList from './contactsList.vue'
  63. import tabbar from '@/mixins/tabbar.js'
  64. export default {
  65. name: 'CustomerIndex',
  66. components: {
  67. ListTabHeader,
  68. CustomerList,
  69. ContactsList
  70. },
  71. mixins: [tabbar],
  72. data() {
  73. return {
  74. type: null,
  75. navIndex: 0,
  76. navList: [
  77. {label: '客户', com: 'CustomerList', noCheck: true, action: 'crm.customer.index'},
  78. {label: '联系人', com: 'ContactsList', noCheck: true, action: 'crm.contacts.index'}
  79. ],
  80. refreshPage: false // 刷新页面标志
  81. }
  82. },
  83. computed: {
  84. activeCom() {
  85. const index = this.navIndex || 0
  86. const auth = this.navList[index].action
  87. if (!this.$auth(auth)) {
  88. this.$toast('权限不足')
  89. return ''
  90. }
  91. return this.navList[index].com
  92. },
  93. placeholderText() {
  94. return this.activeCom === 'CustomerList' ? '请输入客户名称/手机/电话' : '请输入联系人姓名/手机/电话'
  95. }
  96. },
  97. onLoad(opt) {
  98. this.type = opt.type || null
  99. this.navIndex = Number(opt.index) || 0
  100. },
  101. onShow() {
  102. if (this.refreshPage) {
  103. this.$nextTick(function() {
  104. this.refreshPage = false
  105. })
  106. }
  107. },
  108. methods: {
  109. handleCrmSearch() {
  110. const crmType = this.activeCom === 'CustomerList' ? 'customer' : 'contacts'
  111. this.$Router.navigateTo({
  112. url: '/pages_crm/crmSearch',
  113. query: {
  114. type: crmType
  115. }
  116. })
  117. },
  118. handleToStatic() {
  119. this.$Router.navigateTo('/pages_crm/statistics/customer')
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. .ft-statistics {
  126. font-size: 34rpx;
  127. }
  128. .main-container {
  129. .white-btn {
  130. .wk-search {
  131. font-weight: 400;
  132. font-size: 42rpx;
  133. }
  134. }
  135. .search-box {
  136. width: 100%;
  137. padding: 10rpx 32rpx 20rpx;
  138. .box {
  139. width: 100%;
  140. height: 62rpx;
  141. color: #BBBBBB;
  142. background-color: white;
  143. border-radius: 12rpx;
  144. padding: 0 20rpx;
  145. @include left;
  146. .wk-search {
  147. margin-right: 15rpx;
  148. }
  149. }
  150. }
  151. .list-view {
  152. flex: 1;
  153. overflow-y: hidden;
  154. }
  155. }
  156. </style>