更新
This commit is contained in:
1 parent
5718a00e31
commit
1850ac640e
226 files changed
+37772
-12071
No files matched your search
@@ -0,0 +1,320 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="filter-bar">
|
||||
<view class="type-row">
|
||||
<view
|
||||
v-for="t in PARTNER_TYPES"
|
||||
:key="t.value"
|
||||
class="type-item"
|
||||
:class="{ active: partnerType === t.value }"
|
||||
@tap="switchType(t.value)"
|
||||
>
|
||||
<text>{{ t.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="search-box">
|
||||
<FaIcon name="magnifying-glass" color="#94a3b8" :size="16" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search-input"
|
||||
:placeholder="`搜索${partnerTypeLabel(partnerType)}名称`"
|
||||
confirm-type="search"
|
||||
@confirm="refresh"
|
||||
/>
|
||||
<text v-if="keyword" class="search-clear" @tap="clearKeyword">清空</text>
|
||||
</view>
|
||||
<view class="sum-row">
|
||||
<text class="sum-item">共 {{ total }} 家</text>
|
||||
<text class="sum-item">未结合计 ¥{{ moneyText(openTotal) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="loading && !list.length" class="state-box">
|
||||
<text class="state-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="!list.length" class="state-box">
|
||||
<u-empty mode="search" :text="`没有匹配的${partnerTypeLabel(partnerType)}`" />
|
||||
<text class="state-tip">客商建档请在 Web 后台 CRM / 进销存里完成</text>
|
||||
</view>
|
||||
<template v-else>
|
||||
<view v-for="row in list" :key="row.partner_id" class="p-card" @tap="openDetail(row)">
|
||||
<view class="p-top">
|
||||
<text class="p-name">{{ row.partner_name }}</text>
|
||||
<text class="p-open" :class="{ owe: Number(row.open_amount) > 0 }">
|
||||
{{ Number(row.open_amount) > 0 ? `未结 ¥${moneyText(row.open_amount)}` : '已结清' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="p-meta">
|
||||
<text v-if="row.contact_person">{{ row.contact_person }} {{ row.contact_phone || '' }}</text>
|
||||
<text v-if="row.level">等级 {{ row.level }}</text>
|
||||
<text v-if="Number(row.payment_days) > 0">账期 {{ row.payment_days }} 天</text>
|
||||
<text v-if="Number(row.credit_limit) > 0">信用额 ¥{{ moneyText(row.credit_limit) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="finished" class="load-done">
|
||||
<text>{{ list.length ? '没有更多了' : '' }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<view class="fab" @tap="goBills">
|
||||
<FaIcon name="receipt" color="#ffffff" :size="20" />
|
||||
<text>{{ partnerType === 'supplier' ? '应付账单' : '应收账单' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/**
|
||||
* 客商列表(供应商 / 客户同一个页,靠 partner_type 分流)。
|
||||
* 与后端 partner/list 一致:只列正式启用、有归属的对象,公海客户不参与开单也不在这里出现。
|
||||
*/
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app'
|
||||
import FaIcon from '@/components/FaIcon.vue'
|
||||
import { PARTNER_TYPES, fetchPartners, moneyText, partnerTypeLabel } from '@/api/erp.js'
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
|
||||
const list = ref([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const loading = ref(false)
|
||||
const finished = ref(false)
|
||||
const keyword = ref('')
|
||||
const partnerType = ref('customer')
|
||||
|
||||
const openTotal = computed(() => list.value.reduce((sum, r) => sum + Number(r.open_amount || 0), 0))
|
||||
|
||||
onLoad((query = {}) => {
|
||||
if (query.partner_type) partnerType.value = String(query.partner_type) === 'supplier' ? 'supplier' : 'customer'
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
refresh()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
if (finished.value || loading.value) return
|
||||
loadMore()
|
||||
})
|
||||
|
||||
function switchType(value) {
|
||||
if (partnerType.value === value) return
|
||||
partnerType.value = value
|
||||
list.value = []
|
||||
refresh()
|
||||
uni.setNavigationBarTitle({ title: partnerTypeLabel(value) })
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
list.value = []
|
||||
await loadPage()
|
||||
}
|
||||
|
||||
async function loadMore() {
|
||||
page.value += 1
|
||||
await loadPage()
|
||||
}
|
||||
|
||||
async function loadPage() {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await fetchPartners({
|
||||
page: page.value,
|
||||
pageSize: PAGE_SIZE,
|
||||
partnerType: partnerType.value,
|
||||
keyword: keyword.value.trim()
|
||||
})
|
||||
const rows = data.list || []
|
||||
list.value = page.value === 1 ? rows : [...list.value, ...rows]
|
||||
total.value = data.total || 0
|
||||
finished.value = list.value.length >= total.value
|
||||
} catch (e) {
|
||||
if (page.value > 1) page.value -= 1
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function clearKeyword() {
|
||||
keyword.value = ''
|
||||
refresh()
|
||||
}
|
||||
|
||||
function openDetail(row) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/erp/partner/detail?id=${row.partner_id}&partner_type=${partnerType.value}`
|
||||
})
|
||||
}
|
||||
|
||||
function goBills() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/erp/finance/bill?bill_type=${partnerType.value === 'supplier' ? 2 : 1}`
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: $color-bg-page;
|
||||
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
background: $color-bg-page;
|
||||
padding: 20rpx $page-padding-x 8rpx;
|
||||
}
|
||||
|
||||
.type-row {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.type-item {
|
||||
padding: 10rpx 32rpx;
|
||||
border-radius: $radius-full;
|
||||
background: $color-card;
|
||||
font-size: 26rpx;
|
||||
color: $color-text-secondary;
|
||||
box-shadow: $shadow-card;
|
||||
|
||||
&.active {
|
||||
background: #2563eb;
|
||||
color: #ffffff;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.search-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
height: 72rpx;
|
||||
padding: 0 24rpx;
|
||||
background: $color-card;
|
||||
border-radius: $radius-full;
|
||||
box-shadow: $shadow-card;
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
font-size: 26rpx;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.search-clear {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.sum-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 16rpx 8rpx 4rpx;
|
||||
}
|
||||
|
||||
.sum-item {
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.p-card {
|
||||
@include card;
|
||||
margin: 0 $page-padding-x 20rpx;
|
||||
padding: 24rpx 28rpx;
|
||||
|
||||
&:active {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
.p-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.p-name {
|
||||
flex: 1;
|
||||
font-size: 29rpx;
|
||||
font-weight: 500;
|
||||
color: $color-text;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.p-open {
|
||||
flex-shrink: 0;
|
||||
font-size: 25rpx;
|
||||
color: $color-text-muted;
|
||||
|
||||
&.owe {
|
||||
color: #dc2626;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.p-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8rpx 24rpx;
|
||||
margin-top: 10rpx;
|
||||
font-size: 23rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.load-done {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 8rpx 0 24rpx;
|
||||
font-size: 24rpx;
|
||||
color: $color-text-muted;
|
||||
}
|
||||
|
||||
.state-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 120rpx 40rpx;
|
||||
}
|
||||
|
||||
.state-text,
|
||||
.state-tip {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.fab {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
bottom: calc(48rpx + env(safe-area-inset-bottom));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
height: 84rpx;
|
||||
padding: 0 44rpx;
|
||||
border-radius: $radius-full;
|
||||
background: #2563eb;
|
||||
color: #ffffff;
|
||||
font-size: 27rpx;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 8rpx 24rpx rgba(37, 99, 235, 0.4);
|
||||
|
||||
&:active {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user