index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class="client-page">
  3. <erp-nav-bar title="授权客户" :showBack="false" />
  4. <scroll-view scroll-y class="page-body" :show-scrollbar="false" :refresher-enabled="true"
  5. :refresher-triggered="refresherTriggered" @refresherrefresh="onPullDownRefresh">
  6. <!-- 加载中 -->
  7. <view class="loading-wrap" v-if="isLoading">
  8. <text class="loading-text">加载中...</text>
  9. </view>
  10. <!-- 空状态 -->
  11. <view class="empty-wrap" v-else-if="clientList.length === 0">
  12. <view class="empty-icon-box">
  13. <text class="empty-icon">📋</text>
  14. </view>
  15. <text class="empty-title">暂无授权客户</text>
  16. <text class="empty-desc">请联系管理员为您分配客户</text>
  17. </view>
  18. <!-- 客户卡片列表 -->
  19. <view class="client-list" v-else>
  20. <view class="client-card" v-for="(client, idx) in clientList" :key="client.rowId || idx"
  21. @click="goClientOrders(client)">
  22. <view class="card-header">
  23. <view class="card-title-row">
  24. <view class="card-index">{{ idx + 1 }}</view>
  25. <view class="card-name-group">
  26. <text class="card-name">{{ client.name || '-' }}</text>
  27. <text class="card-num" v-if="client.num">{{ client.num }}</text>
  28. </view>
  29. </view>
  30. <view class="card-tag" :class="client.stopUse === 0 ? 'tag-active' : 'tag-stop'">
  31. {{ client.stopUse === 0 ? '正常' : '停用' }}
  32. </view>
  33. </view>
  34. <view class="card-divider"></view>
  35. <view class="card-body">
  36. <view class="info-grid">
  37. <view class="info-item">
  38. <text class="info-label">分类</text>
  39. <text class="info-value">{{ client.clientClass || '-' }}</text>
  40. </view>
  41. <view class="info-item">
  42. <text class="info-label">业务员</text>
  43. <text class="info-value">{{ client.saleMan || '-' }}</text>
  44. </view>
  45. </view>
  46. <view class="contact-row" v-if="client.contactMan || client.contactTel || client.contactMobile">
  47. <image class="contact-icon" src="https://img.icons8.com/ios-glyphs/28/999999/phone--v1.png"
  48. mode="aspectFit"></image>
  49. <text class="contact-text">{{ client.contactMan || '' }} {{ client.contactMobile ||
  50. client.contactTel || '' }}</text>
  51. </view>
  52. <view class="addr-row" v-if="client.contactAddr">
  53. <image class="addr-icon" src="https://img.icons8.com/ios-glyphs/28/999999/marker--v1.png"
  54. mode="aspectFit"></image>
  55. <text class="addr-text">{{ client.contactAddr }}</text>
  56. </view>
  57. </view>
  58. <view class="card-footer" v-if="client.enterDate">
  59. <text class="footer-text">加入时间 {{ formatDate(client.enterDate) }}</text>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 底部安全距离 -->
  64. <view class="safe-bottom"></view>
  65. </scroll-view>
  66. <erp-tab-bar active="client"></erp-tab-bar>
  67. </view>
  68. </template>
  69. <script>
  70. import ErpNavBar from '@/components/erp-nav-bar.vue';
  71. import ErpTabBar from '@/components/erp-tab-bar.vue';
  72. import { getMyInfo } from '@/api/system/employee.js';
  73. import { getClientByIds } from '@/api/erp/client.js';
  74. export default {
  75. components: { ErpNavBar, ErpTabBar },
  76. data() {
  77. return {
  78. isLoading: true,
  79. refresherTriggered: false,
  80. clientList: []
  81. }
  82. },
  83. computed: {},
  84. async onLoad() {
  85. await this.loadClients();
  86. },
  87. methods: {
  88. onPullDownRefresh() {
  89. this.refresherTriggered = true;
  90. this.loadClients().finally(() => {
  91. this.refresherTriggered = false;
  92. });
  93. },
  94. async loadClients() {
  95. try {
  96. const infoRes = await getMyInfo();
  97. const ids = infoRes.data?.authClientFRowIDs;
  98. if (ids) {
  99. const clientRes = await getClientByIds(ids);
  100. this.clientList = clientRes.data || [];
  101. }
  102. } catch (e) {
  103. console.error('加载客户列表失败', e);
  104. uni.showToast({ title: e || '加载失败', icon: 'none' });
  105. } finally {
  106. this.isLoading = false;
  107. }
  108. },
  109. formatDate(dateStr) {
  110. if (!dateStr) return '';
  111. const d = new Date(dateStr.replace(/-/g, '/'));
  112. const y = d.getFullYear();
  113. const m = String(d.getMonth() + 1).padStart(2, '0');
  114. const day = String(d.getDate()).padStart(2, '0');
  115. return `${y}-${m}-${day}`;
  116. },
  117. goClientOrders(client) {
  118. uni.navigateTo({
  119. url: `/pages/order/list/index?clientId=${client.rowId}&clientName=${encodeURIComponent(client.name || '')}`
  120. });
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. .client-page {
  127. width: 100vw;
  128. height: 100vh;
  129. background: #f5f6f8;
  130. display: flex;
  131. flex-direction: column;
  132. overflow: hidden;
  133. }
  134. .page-body {
  135. flex: 1;
  136. height: 0;
  137. padding: 24rpx 32rpx 0;
  138. }
  139. /* ========== 加载 & 空状态 ========== */
  140. .loading-wrap {
  141. display: flex;
  142. justify-content: center;
  143. padding: 120rpx 0;
  144. }
  145. .loading-text {
  146. font-size: 28rpx;
  147. color: #bbb;
  148. }
  149. .empty-wrap {
  150. display: flex;
  151. flex-direction: column;
  152. align-items: center;
  153. padding: 140rpx 0;
  154. }
  155. .empty-icon-box {
  156. width: 120rpx;
  157. height: 120rpx;
  158. border-radius: 50%;
  159. background: #f0f1f5;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. margin-bottom: 28rpx;
  164. }
  165. .empty-icon {
  166. font-size: 56rpx;
  167. }
  168. .empty-title {
  169. font-size: 30rpx;
  170. font-weight: 600;
  171. color: #555;
  172. margin-bottom: 12rpx;
  173. }
  174. .empty-desc {
  175. font-size: 26rpx;
  176. color: #bbb;
  177. }
  178. /* ========== 客户卡片 ========== */
  179. .client-list {
  180. display: flex;
  181. flex-direction: column;
  182. gap: 20rpx;
  183. }
  184. .client-card {
  185. background: #fff;
  186. border-radius: 20rpx;
  187. padding: 28rpx 32rpx 0;
  188. box-shadow: 0 2rpx 16rpx rgba(0, 0, 0, 0.03);
  189. overflow: hidden;
  190. transition: transform 0.15s;
  191. }
  192. .client-card:active {
  193. transform: scale(0.98);
  194. }
  195. .card-header {
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: flex-start;
  199. }
  200. .card-title-row {
  201. display: flex;
  202. align-items: flex-start;
  203. flex: 1;
  204. min-width: 0;
  205. }
  206. .card-index {
  207. width: 44rpx;
  208. height: 44rpx;
  209. border-radius: 12rpx;
  210. background: #f0f1f5;
  211. color: #888;
  212. font-size: 22rpx;
  213. font-weight: 700;
  214. display: flex;
  215. align-items: center;
  216. justify-content: center;
  217. margin-right: 16rpx;
  218. flex-shrink: 0;
  219. margin-top: 2rpx;
  220. }
  221. .card-name-group {
  222. flex: 1;
  223. min-width: 0;
  224. }
  225. .card-name {
  226. font-size: 32rpx;
  227. font-weight: 600;
  228. color: #1a1a1a;
  229. display: block;
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. white-space: nowrap;
  233. }
  234. .card-num {
  235. font-size: 24rpx;
  236. color: #b0b0b0;
  237. display: block;
  238. margin-top: 4rpx;
  239. }
  240. .card-tag {
  241. font-size: 22rpx;
  242. font-weight: 500;
  243. padding: 6rpx 18rpx;
  244. border-radius: 20rpx;
  245. flex-shrink: 0;
  246. }
  247. .tag-active {
  248. background: rgba(193, 0, 28, 0.06);
  249. color: #C1001C;
  250. }
  251. .tag-stop {
  252. background: #f5f5f5;
  253. color: #bbb;
  254. }
  255. .card-divider {
  256. height: 1rpx;
  257. background: #f0f0f0;
  258. margin: 22rpx 0;
  259. }
  260. .card-body {
  261. padding-bottom: 4rpx;
  262. }
  263. .info-grid {
  264. display: grid;
  265. grid-template-columns: 1fr 1fr;
  266. gap: 20rpx 32rpx;
  267. }
  268. .info-item {
  269. display: flex;
  270. flex-direction: column;
  271. gap: 6rpx;
  272. }
  273. .info-label {
  274. font-size: 22rpx;
  275. color: #bbb;
  276. }
  277. .info-value {
  278. font-size: 26rpx;
  279. color: #444;
  280. font-weight: 500;
  281. overflow: hidden;
  282. text-overflow: ellipsis;
  283. white-space: nowrap;
  284. }
  285. .contact-row {
  286. display: flex;
  287. align-items: center;
  288. margin-top: 20rpx;
  289. padding-top: 20rpx;
  290. border-top: 1rpx solid #f7f7f7;
  291. }
  292. .contact-icon {
  293. width: 28rpx;
  294. height: 28rpx;
  295. margin-right: 10rpx;
  296. flex-shrink: 0;
  297. }
  298. .contact-text {
  299. font-size: 24rpx;
  300. color: #888;
  301. }
  302. .addr-row {
  303. display: flex;
  304. align-items: center;
  305. margin-top: 12rpx;
  306. }
  307. .addr-icon {
  308. width: 28rpx;
  309. height: 28rpx;
  310. margin-right: 10rpx;
  311. flex-shrink: 0;
  312. }
  313. .addr-text {
  314. font-size: 24rpx;
  315. color: #888;
  316. overflow: hidden;
  317. text-overflow: ellipsis;
  318. white-space: nowrap;
  319. }
  320. .card-footer {
  321. border-top: 1rpx solid #f7f7f7;
  322. padding: 18rpx 0;
  323. margin-top: 20rpx;
  324. }
  325. .footer-text {
  326. font-size: 22rpx;
  327. color: #ccc;
  328. }
  329. /* ========== 底部 ========== */
  330. .safe-bottom {
  331. height: 140rpx;
  332. }
  333. </style>