ywy_list.vue 8.9 KB

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