ywy_list.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. },
  147. viewSalesData(id) { console.log('查看销售数据 ID:', id); this.build() },
  148. editSalesperson(id) {
  149. uni.navigateTo({ url: '/pages/cjx/hexiao/jxs/add_ywy?id='+id });
  150. console.log('编辑业务员 ID:', id); },
  151. viewPatrolRecords(id) { console.log('查看巡店记录 ID:', id); this.build()},
  152. deleteSalesperson(id) {
  153. let self = this;
  154. uni.showModal({
  155. title: '确认删除',
  156. content: '您确定要删除该业务员吗?',
  157. confirmColor: '#e54d42',
  158. success: (res) => {
  159. if (res.confirm) {
  160. delYwy(id).then(res=>{
  161. self.fetchSalespeople(true);
  162. })
  163. }
  164. }
  165. });
  166. },
  167. addNewSalesperson() {
  168. console.log('跳转到新增业务员页面');
  169. uni.navigateTo({ url: '/pages/cjx/hexiao/jxs/add_ywy' });
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .page-container {
  176. display: flex;
  177. flex-direction: column;
  178. height: 100vh;
  179. background-color: #f5f6fa;
  180. }
  181. .search-wrapper {
  182. padding: 20rpx;
  183. background-color: #ffffff;
  184. border-bottom: 1rpx solid #f0f0f0;
  185. }
  186. .search-bar {
  187. display: flex;
  188. align-items: center;
  189. background-color: #f5f6fa;
  190. border-radius: 50rpx;
  191. padding: 0 25rpx;
  192. height: 70rpx;
  193. }
  194. .search-input { flex: 1; font-size: 28rpx; margin-left: 15rpx; }
  195. .placeholder { color: #b0b0b0; }
  196. .list-container {
  197. flex: 1;
  198. height: 100%;
  199. padding-bottom: 160rpx; // 为底部按钮留出空间
  200. }
  201. .empty-list { text-align: center; color: #999; padding-top: 150rpx; }
  202. .salesperson-card {
  203. background-color: #ffffff;
  204. border-radius: 16rpx;
  205. margin: 20rpx;
  206. padding: 30rpx;
  207. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  208. }
  209. .card-header {
  210. display: flex;
  211. justify-content: space-between;
  212. align-items: center;
  213. .header-left {
  214. display: flex;
  215. align-items: center;
  216. }
  217. .salesperson-name {
  218. font-size: 32rpx;
  219. font-weight: bold;
  220. color: #333;
  221. margin-left: 15rpx;
  222. }
  223. }
  224. .status-badge {
  225. font-size: 24rpx;
  226. padding: 6rpx 16rpx;
  227. border-radius: 8rpx;
  228. color: #fff;
  229. &.active {
  230. background-color: #3c82f8;
  231. }
  232. &.inactive {
  233. background-color: #c0c4cc;
  234. }
  235. }
  236. .card-body {
  237. padding: 20rpx 0;
  238. }
  239. .detail-row {
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. padding: 15rpx 0;
  244. font-size: 28rpx;
  245. .detail-label { color: #666; }
  246. .detail-value { color: #333; }
  247. .with-arrow {
  248. display: flex;
  249. align-items: center;
  250. color: #999;
  251. .view-text {
  252. color: #3c82f8;
  253. }
  254. }
  255. &.clickable:active {
  256. background-color: #f9f9f9;
  257. }
  258. }
  259. .card-footer {
  260. display: flex;
  261. justify-content: space-around;
  262. border-top: 1rpx solid #f5f5f5;
  263. margin-top: 10rpx;
  264. padding-top: 25rpx;
  265. }
  266. .action-btn {
  267. display: flex;
  268. align-items: center;
  269. font-size: 26rpx;
  270. color: #3c82f8;
  271. text { margin-left: 8rpx; }
  272. &.delete-btn { color: #e54d42; }
  273. }
  274. .fixed-footer {
  275. position: fixed;
  276. bottom: 0;
  277. left: 0;
  278. width: 100%;
  279. background-color: #f5f6fa;
  280. padding: 20rpx 30rpx;
  281. padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
  282. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  283. box-sizing: border-box;
  284. z-index: 100;
  285. }
  286. .add-btn {
  287. background-color: #3c82f8;
  288. color: white;
  289. border-radius: 50rpx;
  290. font-size: 32rpx;
  291. height: 90rpx;
  292. line-height: 90rpx;
  293. &::after { border: none; }
  294. }
  295. </style>