ywy_list.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <view class="page-container">
  3. <view class="search-wrapper">
  4. <view class="search-bar">
  5. <uni-icons type="search" size="20" color="#999"></uni-icons>
  6. <input
  7. class="search-input"
  8. v-model="searchQuery"
  9. placeholder="输入业务员姓名/账号搜索"
  10. placeholder-class="placeholder"
  11. confirm-type="search"
  12. @confirm="handleSearch"
  13. />
  14. </view>
  15. </view>
  16. <scroll-view class="list-container" scroll-y="true" @scrolltolower="loadMore">
  17. <view v-if="salespersonList.length === 0 && loadStatus !== 'loading'" class="empty-list">
  18. <text>暂无业务员数据</text>
  19. </view>
  20. <view v-for="item in salespersonList" :key="item.id" class="salesperson-card">
  21. <view class="card-header">
  22. <view class="header-left">
  23. <uni-icons type="person-filled" size="22" color="#3c82f8"></uni-icons>
  24. <text class="salesperson-name">{{ item.nick_name }}</text>
  25. </view>
  26. <view class="status-badge" :class="item.is_job ? 'active' : 'inactive'">
  27. {{ item.is_job ? '在职' : '离职' }}
  28. </view>
  29. </view>
  30. <view class="card-body">
  31. <view class="detail-row" @click="copy(item.account)">
  32. <text class="detail-label">业务员账号</text>
  33. <text class="detail-value">{{ item.tel_ }}</text>
  34. </view>
  35. <view class="detail-row clickable" @click="goToStores(item.id)">
  36. <text class="detail-label">门店数量</text>
  37. <view class="detail-value with-arrow">
  38. <text>{{ item.storeCount }}家</text>
  39. <uni-icons type="right" size="14" color="#999"></uni-icons>
  40. </view>
  41. </view>
  42. <view class="detail-row">
  43. <text class="detail-label">创建时间</text>
  44. <text class="detail-value">{{ item.create_time }}</text>
  45. </view>
  46. <view class="detail-row clickable" @click="viewSalesData(item.id)">
  47. <text class="detail-label">销售数据</text>
  48. <view class="detail-value with-arrow">
  49. <text class="view-text">查看</text>
  50. <uni-icons type="right" size="14" color="#999"></uni-icons>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="card-footer">
  55. <view class="action-btn" @click="editSalesperson(item.id)">
  56. <uni-icons type="compose" size="18" color="#3c82f8"></uni-icons>
  57. <text>编辑</text>
  58. </view>
  59. <view class="action-btn" @click="viewPatrolRecords(item.id)">
  60. <uni-icons type="home-filled" size="18" color="#3c82f8"></uni-icons>
  61. <text>巡店记录</text>
  62. </view>
  63. <view class="action-btn delete-btn" @click="deleteSalesperson(item.id)">
  64. <uni-icons type="trash-filled" size="18" color="#e54d42"></uni-icons>
  65. <text>删除</text>
  66. </view>
  67. </view>
  68. </view>
  69. <uni-load-more :status="loadStatus"></uni-load-more>
  70. </scroll-view>
  71. <view class="fixed-footer">
  72. <button class="add-btn" @click="addNewSalesperson">新增业务员</button>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import {ywyList,delYwy} from "../../../../api/hexiao";
  78. export default {
  79. data() {
  80. return {
  81. searchQuery: '',
  82. salespersonList: [],
  83. pagination: { page: 1, limit: 10 },
  84. loadStatus: 'more',
  85. isLoading: false,
  86. };
  87. },
  88. onLoad() {
  89. this.fetchSalespeople(true);
  90. },
  91. onShow(){
  92. this.fetchSalespeople(true);
  93. },
  94. onPullDownRefresh() {
  95. // this.fetchSalespeople(true);
  96. },
  97. methods: {
  98. build(){
  99. uni.showToast({
  100. title: '功能建设中',
  101. icon: 'none'
  102. });
  103. },
  104. fetchSalespeople(isRefresh = false) {
  105. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  106. return;
  107. }
  108. if (isRefresh) {
  109. this.pagination.page = 1;
  110. this.salespersonList = [];
  111. this.loadStatus = 'more';
  112. }
  113. this.isLoading = true;
  114. this.loadStatus = 'loading';
  115. // --- 模拟API请求 ---
  116. console.log(`请求第 ${this.pagination.page} 页...`);
  117. ywyList(this.searchQuery).then(res=>{
  118. let mockData = res.data;
  119. this.salespersonList = mockData
  120. // uni.stopPullDownRefresh();
  121. // if (mockData.length > 0 && !noMoreData) {
  122. // this.salespersonList = [...this.salespersonList, ...mockData];
  123. // this.pagination.page++;
  124. // this.loadStatus = 'more';
  125. // } else {
  126. // this.loadStatus = 'noMore';
  127. // }
  128. this.isLoading = false;
  129. this.loadStatus = 'noMore';
  130. })
  131. },
  132. loadMore() {
  133. this.fetchSalespeople();
  134. },
  135. handleSearch() {
  136. // uni.showToast({ title: '触发搜索', icon: 'none' });
  137. this.fetchSalespeople(true);
  138. },
  139. copy(text) {
  140. uni.setClipboardData({
  141. data: text,
  142. success: () => uni.showToast({ title: '已复制' })
  143. });
  144. },
  145. goToStores(id) {
  146. uni.navigateTo({ url: '/pages/cjx/hexiao/ywy/retail?id='+id });
  147. },
  148. viewSalesData(id) {
  149. console.log('查看销售数据 ID:', id);
  150. uni.navigateTo({ url: '/pages/cjx/xiaoshou/index?type=2&ywyId='+id });
  151. },
  152. editSalesperson(id) {
  153. uni.navigateTo({ url: '/pages/cjx/hexiao/jxs/add_ywy?id='+id });
  154. console.log('编辑业务员 ID:', id); },
  155. viewPatrolRecords(id) {
  156. uni.navigateTo({ url: '/pages/cjx/hexiao/ywy/patrol_record?id='+id });
  157. },
  158. deleteSalesperson(id) {
  159. let self = this;
  160. uni.showModal({
  161. title: '确认删除',
  162. content: '您确定要删除该业务员吗?',
  163. confirmColor: '#e54d42',
  164. success: (res) => {
  165. if (res.confirm) {
  166. delYwy(id).then(res=>{
  167. self.fetchSalespeople(true);
  168. })
  169. }
  170. }
  171. });
  172. },
  173. addNewSalesperson() {
  174. console.log('跳转到新增业务员页面');
  175. uni.navigateTo({ url: '/pages/cjx/hexiao/jxs/add_ywy' });
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .page-container {
  182. display: flex;
  183. flex-direction: column;
  184. height: 100vh;
  185. background-color: #f5f6fa;
  186. }
  187. .search-wrapper {
  188. padding: 20rpx;
  189. background-color: #ffffff;
  190. border-bottom: 1rpx solid #f0f0f0;
  191. }
  192. .search-bar {
  193. display: flex;
  194. align-items: center;
  195. background-color: #f5f6fa;
  196. border-radius: 50rpx;
  197. padding: 0 25rpx;
  198. height: 70rpx;
  199. }
  200. .search-input { flex: 1; font-size: 28rpx; margin-left: 15rpx; }
  201. .placeholder { color: #b0b0b0; }
  202. .list-container {
  203. flex: 1;
  204. height: 100%;
  205. padding-bottom: 160rpx; // 为底部按钮留出空间
  206. }
  207. .empty-list { text-align: center; color: #999; padding-top: 150rpx; }
  208. .salesperson-card {
  209. background-color: #ffffff;
  210. border-radius: 16rpx;
  211. margin: 20rpx;
  212. padding: 30rpx;
  213. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  214. }
  215. .card-header {
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. .header-left {
  220. display: flex;
  221. align-items: center;
  222. }
  223. .salesperson-name {
  224. font-size: 32rpx;
  225. font-weight: bold;
  226. color: #333;
  227. margin-left: 15rpx;
  228. }
  229. }
  230. .status-badge {
  231. font-size: 24rpx;
  232. padding: 6rpx 16rpx;
  233. border-radius: 8rpx;
  234. color: #fff;
  235. &.active {
  236. background-color: #3c82f8;
  237. }
  238. &.inactive {
  239. background-color: #c0c4cc;
  240. }
  241. }
  242. .card-body {
  243. padding: 20rpx 0;
  244. }
  245. .detail-row {
  246. display: flex;
  247. justify-content: space-between;
  248. align-items: center;
  249. padding: 15rpx 0;
  250. font-size: 28rpx;
  251. .detail-label { color: #666; }
  252. .detail-value { color: #333; }
  253. .with-arrow {
  254. display: flex;
  255. align-items: center;
  256. color: #999;
  257. .view-text {
  258. color: #3c82f8;
  259. }
  260. }
  261. &.clickable:active {
  262. background-color: #f9f9f9;
  263. }
  264. }
  265. .card-footer {
  266. display: flex;
  267. justify-content: space-around;
  268. border-top: 1rpx solid #f5f5f5;
  269. margin-top: 10rpx;
  270. padding-top: 25rpx;
  271. }
  272. .action-btn {
  273. display: flex;
  274. align-items: center;
  275. font-size: 26rpx;
  276. color: #3c82f8;
  277. text { margin-left: 8rpx; }
  278. &.delete-btn { color: #e54d42; }
  279. }
  280. .fixed-footer {
  281. position: fixed;
  282. bottom: 0;
  283. left: 0;
  284. width: 100%;
  285. background-color: #f5f6fa;
  286. padding: 20rpx 30rpx;
  287. padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
  288. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  289. box-sizing: border-box;
  290. z-index: 100;
  291. }
  292. .add-btn {
  293. background-color: #3c82f8;
  294. color: white;
  295. border-radius: 50rpx;
  296. font-size: 32rpx;
  297. height: 90rpx;
  298. line-height: 90rpx;
  299. &::after { border: none; }
  300. }
  301. </style>