index.vue 8.9 KB

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