index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="mobileWrapper">
  3. <div class="fixedTop">
  4. <van-nav-bar
  5. title="重点客户"
  6. right-text="新建"
  7. v-preventReClick
  8. @click-right="onClickRight"
  9. />
  10. <van-search
  11. v-model="queryParams.companyName"
  12. show-action
  13. label="客户"
  14. placeholder="请输入客户名称"
  15. @search="onSearch"
  16. >
  17. <template #action>
  18. <div @click="onSearch" v-preventReClick>搜索</div>
  19. </template>
  20. </van-search>
  21. </div>
  22. <div class="listWrapper">
  23. <!-- 内容 -->
  24. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  25. <van-list
  26. v-model="loading"
  27. :finished="finished"
  28. finished-text=""
  29. @load="onLoad"
  30. class="list"
  31. >
  32. <div
  33. class="item"
  34. v-for="(item, index) in list"
  35. :key="index"
  36. v-preventReClick
  37. @click="toDetail(item.id)"
  38. >
  39. <div>{{ item.companyName }}</div>
  40. <div>负责人:{{ item.createBy }}</div>
  41. <van-tag class="public-margin-t-10" type="primary" size="large">{{
  42. item.companyEnterprisepro
  43. }}</van-tag>
  44. <van-tag class="public-margin-l-10" type="primary" size="large">{{
  45. item.companyState
  46. }}</van-tag>
  47. </div>
  48. </van-list>
  49. </van-pull-refresh>
  50. <div v-if="noDate" class="noDateWrapper">
  51. <div>没有相关数据</div>
  52. <div>您可以尝试以下操作</div>
  53. <van-button type="info" round v-preventReClick @click="onClickRight"
  54. >新建重点客户</van-button
  55. >
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script>
  61. import { get_customer_list } from "@/api/mobile/crm/index";
  62. export default {
  63. name: "MobileCrmIndex",
  64. data() {
  65. return {
  66. list: [],
  67. refreshing: false,
  68. loading: false,
  69. finished: false,
  70. noDate: false,
  71. // 查询参数
  72. queryParams: {
  73. pageNum: 1,
  74. pageSize: 10,
  75. companyName: null,
  76. },
  77. };
  78. },
  79. created() {},
  80. mounted() {},
  81. methods: {
  82. toDetail(id) {
  83. this.$router.push({ path: "detail", query: { id } });
  84. },
  85. onRefresh() {
  86. // 清空列表数据
  87. this.finished = false;
  88. // 将 loading 设置为 true,表示处于加载状态
  89. this.loading = true;
  90. this.onLoad();
  91. },
  92. onClickRight() {
  93. this.$router.push({ name: "MobileCrmForm", query: { type: 1 } });
  94. },
  95. onSearch() {
  96. this.getList();
  97. },
  98. onLoad() {
  99. this.getList();
  100. },
  101. getList() {
  102. let that = this;
  103. if (this.refreshing) {
  104. this.list = [];
  105. this.refreshing = false;
  106. }
  107. that.$toast.loading({
  108. duration: 0,
  109. forbidClick: true,
  110. message: "加载中...",
  111. });
  112. get_customer_list(that.queryParams)
  113. .then((response) => {
  114. if (response.code == 200) {
  115. that.$toast.clear();
  116. let data = response.rows,
  117. total = response.total;
  118. that.finished = true;
  119. that.noDate = false;
  120. if (total == 0) {
  121. that.list = [];
  122. that.noDate = true;
  123. } else if (total < 10) {
  124. that.list = data;
  125. } else {
  126. that.finished = false;
  127. that.list.push(...data);
  128. that.queryParams.page += 1;
  129. }
  130. that.loading = false;
  131. }
  132. })
  133. .catch((err) => {
  134. that.$toast(err.msg);
  135. });
  136. },
  137. },
  138. };
  139. </script>
  140. <style lang="scss">
  141. .fixedTop{
  142. width:100%;
  143. position: fixed;
  144. top:0;
  145. left:0;
  146. z-index: 99;
  147. }
  148. .listWrapper {
  149. margin-top:100px;
  150. background: #f4f4f4;
  151. // padding-bottom:100px;
  152. }
  153. .searchBar {
  154. text-align: center;
  155. background: #fff;
  156. padding: 10px 0;
  157. }
  158. .list {
  159. width: 100%;
  160. .item {
  161. margin: 10px 0;
  162. padding: 10px 3%;
  163. background: #fff;
  164. color: #aaa;
  165. font-size: 14px;
  166. // border: 1px solid #ccc;
  167. > div:first-child {
  168. font-weight: bold;
  169. font-size: 18px;
  170. line-height: 30px;
  171. color: #333;
  172. }
  173. }
  174. }
  175. .noDateWrapper {
  176. width: 100%;
  177. text-align: center;
  178. position: absolute;
  179. top: 50%;
  180. left: 50%;
  181. transform: translate(-50%, -50%);
  182. > div {
  183. color: #8a8989;
  184. }
  185. button {
  186. margin-top: 10px;
  187. }
  188. }
  189. </style>