525 lines
11 KiB
Vue
525 lines
11 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view class="tab-bar">
|
|
<view
|
|
v-for="bt in BILL_TYPES"
|
|
:key="bt.value"
|
|
class="tab"
|
|
:class="{ active: billType === bt.value }"
|
|
@tap="switchType(bt.value)"
|
|
>
|
|
<text class="tab-label">{{ bt.label }}</text>
|
|
<text class="tab-sum">未{{ bt.value === 1 ? '收' : '付' }} ¥{{ moneyText(openOf(bt.value)) }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="filter-bar">
|
|
<view class="search-box">
|
|
<FaIcon name="magnifying-glass" color="#94a3b8" :size="16" />
|
|
<input
|
|
v-model="keyword"
|
|
class="search-input"
|
|
placeholder="搜索客商 / 单据号"
|
|
confirm-type="search"
|
|
@confirm="refresh"
|
|
/>
|
|
<text v-if="keyword" class="search-clear" @tap="clearKeyword">清空</text>
|
|
</view>
|
|
<view class="chip-row">
|
|
<view
|
|
v-for="opt in STATE_OPTIONS"
|
|
:key="opt.value || 'all'"
|
|
class="chip"
|
|
:class="{ active: settleState === opt.value }"
|
|
@tap="onState(opt.value)"
|
|
>
|
|
<text>{{ opt.label }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="date-row">
|
|
<picker mode="date" :value="dateFrom" @change="onDate('from', $event)">
|
|
<view class="date-cell">
|
|
<FaIcon name="calendar-days" color="#94a3b8" :size="14" />
|
|
<text>{{ dateFrom || '开始日期' }}</text>
|
|
</view>
|
|
</picker>
|
|
<text class="date-sep">至</text>
|
|
<picker mode="date" :value="dateTo" @change="onDate('to', $event)">
|
|
<view class="date-cell">
|
|
<FaIcon name="calendar-days" color="#94a3b8" :size="14" />
|
|
<text>{{ dateTo || '结束日期' }}</text>
|
|
</view>
|
|
</picker>
|
|
<text v-if="dateFrom || dateTo" class="date-clear" @tap="clearDates">重置</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="sum-bar">
|
|
<text class="sum-item">共 {{ total }} 张账单</text>
|
|
<text v-if="partnerName" class="sum-item" @tap="clearPartner">已筛「{{ partnerName }}」×</text>
|
|
</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="`没有${billTypeLabel}账单`" />
|
|
</view>
|
|
<template v-else>
|
|
<view v-for="row in list" :key="row.id" class="f-card" @tap="openBill(row)">
|
|
<view class="f-top">
|
|
<text class="f-partner">{{ row.partner_name }}</text>
|
|
<u-tag :text="row.status_label" :type="row.status === 2 ? 'success' : row.status === 1 ? 'primary' : 'warning'" size="mini" />
|
|
</view>
|
|
<text class="f-sub">{{ row.source_doc_no || '手工账单' }} · {{ row.bill_date }}</text>
|
|
<view class="f-amounts">
|
|
<view class="f-cell">
|
|
<text class="cell-label">{{ billType === 1 ? '应收' : '应付' }}</text>
|
|
<text class="cell-value">¥{{ moneyText(row.amount) }}</text>
|
|
</view>
|
|
<view class="f-cell">
|
|
<text class="cell-label">已核销</text>
|
|
<text class="cell-value">¥{{ moneyText(row.settled_amount) }}</text>
|
|
</view>
|
|
<view class="f-cell">
|
|
<text class="cell-label">{{ billType === 1 ? '未收' : '未付' }}</text>
|
|
<text class="cell-value open">¥{{ moneyText(row.balance) }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="f-foot">
|
|
<text class="foot-due">{{ row.due_date ? `到期 ${row.due_date}` : '未设账期' }}</text>
|
|
<text v-if="row.overdue_days > 0" class="foot-over">逾期 {{ row.overdue_days }} 天</text>
|
|
<text v-else-if="row.status !== 2" class="foot-ok">账期内</text>
|
|
</view>
|
|
</view>
|
|
<view v-if="finished" class="load-done">
|
|
<text>{{ list.length ? '没有更多了' : '' }}</text>
|
|
</view>
|
|
</template>
|
|
|
|
<view class="fab" @tap="goFund">
|
|
<FaIcon name="money-bill-wave" color="#ffffff" :size="18" />
|
|
<text>{{ billType === 1 ? '登记收款' : '登记付款' }}</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
/**
|
|
* 应收应付账单列表。
|
|
* 「未收/未付合计」用的是接口随列表返回的全量汇总,不是本页累加,翻页也不会跳数。
|
|
*/
|
|
import { computed, ref } from 'vue'
|
|
import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app'
|
|
import FaIcon from '@/components/FaIcon.vue'
|
|
import { BILL_TYPES, SETTLE_STATES, fetchBills, moneyText } from '@/api/erp.js'
|
|
|
|
const PAGE_SIZE = 20
|
|
|
|
const STATE_OPTIONS = [{ value: '', label: '全部' }, ...SETTLE_STATES]
|
|
|
|
const list = ref([])
|
|
const total = ref(0)
|
|
const page = ref(1)
|
|
const loading = ref(false)
|
|
const finished = ref(false)
|
|
const billType = ref(1)
|
|
const partnerId = ref('')
|
|
const partnerName = ref('')
|
|
const keyword = ref('')
|
|
const settleState = ref('')
|
|
const dateFrom = ref('')
|
|
const dateTo = ref('')
|
|
const summary = ref({ openReceivable: 0, openPayable: 0 })
|
|
|
|
const billTypeLabel = computed(() => (billType.value === 1 ? '应收' : '应付'))
|
|
|
|
onLoad((query = {}) => {
|
|
if (query.bill_type) billType.value = Number(query.bill_type) === 2 ? 2 : 1
|
|
if (query.partner_id) {
|
|
partnerId.value = String(query.partner_id)
|
|
partnerName.value = decodeURIComponent(query.partner_name || '')
|
|
}
|
|
if (query.settle_state) settleState.value = String(query.settle_state)
|
|
})
|
|
|
|
onShow(() => refresh())
|
|
|
|
onReachBottom(() => {
|
|
if (finished.value || loading.value) return
|
|
loadMore()
|
|
})
|
|
|
|
function openOf(type) {
|
|
return type === 1 ? summary.value.openReceivable : summary.value.openPayable
|
|
}
|
|
|
|
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 fetchBills({
|
|
page: page.value,
|
|
pageSize: PAGE_SIZE,
|
|
billType: billType.value,
|
|
partnerId: partnerId.value,
|
|
partnerType: billType.value === 1 ? 'customer' : 'supplier',
|
|
settleState: settleState.value,
|
|
keyword: keyword.value.trim(),
|
|
dateFrom: dateFrom.value,
|
|
dateTo: dateTo.value
|
|
})
|
|
const rows = data.list || []
|
|
list.value = page.value === 1 ? rows : [...list.value, ...rows]
|
|
total.value = data.total || 0
|
|
summary.value = data.summary || summary.value
|
|
finished.value = list.value.length >= total.value
|
|
} catch (e) {
|
|
if (page.value > 1) page.value -= 1
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
function switchType(value) {
|
|
if (billType.value === value) return
|
|
billType.value = value
|
|
// 应收只看客户、应付只看供应商,跨类型带的客商筛选必须一起清掉
|
|
partnerId.value = ''
|
|
partnerName.value = ''
|
|
refresh()
|
|
}
|
|
|
|
function clearPartner() {
|
|
partnerId.value = ''
|
|
partnerName.value = ''
|
|
refresh()
|
|
}
|
|
|
|
function clearKeyword() {
|
|
keyword.value = ''
|
|
refresh()
|
|
}
|
|
|
|
function onState(value) {
|
|
if (settleState.value === value) return
|
|
settleState.value = value
|
|
refresh()
|
|
}
|
|
|
|
function onDate(key, e) {
|
|
const val = e.detail.value
|
|
if (key === 'from') dateFrom.value = val
|
|
else dateTo.value = val
|
|
if (dateFrom.value && dateTo.value && dateFrom.value > dateTo.value) dateFrom.value = dateTo.value
|
|
refresh()
|
|
}
|
|
|
|
function clearDates() {
|
|
dateFrom.value = ''
|
|
dateTo.value = ''
|
|
refresh()
|
|
}
|
|
|
|
function openBill(row) {
|
|
uni.navigateTo({ url: `/pages/erp/finance/bill-detail?id=${row.id}` })
|
|
}
|
|
|
|
function goFund() {
|
|
const q = `fund_type=${billType.value}${partnerId.value ? `&partner_id=${partnerId.value}&partner_name=${encodeURIComponent(partnerName.value)}` : ''}`
|
|
uni.navigateTo({ url: `/pages/erp/finance/fund-edit?${q}` })
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '@/src/styles/page-common.scss';
|
|
|
|
.page {
|
|
min-height: 100vh;
|
|
background: $color-bg-page;
|
|
padding-bottom: 160rpx;
|
|
}
|
|
|
|
.tab-bar {
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 10;
|
|
display: flex;
|
|
background: $color-card;
|
|
box-shadow: $shadow-header;
|
|
}
|
|
|
|
.tab {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 6rpx;
|
|
padding: 22rpx 0 18rpx;
|
|
position: relative;
|
|
|
|
.tab-label {
|
|
font-size: 27rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.tab-sum {
|
|
font-size: 21rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
&.active {
|
|
.tab-label {
|
|
color: $color-primary;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.tab-sum {
|
|
color: $color-primary-dark;
|
|
}
|
|
|
|
&::after {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 50%;
|
|
width: 60rpx;
|
|
height: 6rpx;
|
|
margin-left: -30rpx;
|
|
border-radius: 3rpx;
|
|
background: $color-primary;
|
|
}
|
|
}
|
|
}
|
|
|
|
.filter-bar {
|
|
padding: 20rpx $page-padding-x 8rpx;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
}
|
|
|
|
.chip-row {
|
|
display: flex;
|
|
gap: 14rpx;
|
|
margin-top: 18rpx;
|
|
}
|
|
|
|
.chip {
|
|
padding: 10rpx 22rpx;
|
|
border-radius: $radius-full;
|
|
background: $color-card;
|
|
font-size: 23rpx;
|
|
color: $color-text-secondary;
|
|
box-shadow: $shadow-card;
|
|
|
|
&.active {
|
|
background: #2563eb;
|
|
color: #ffffff;
|
|
}
|
|
}
|
|
|
|
.date-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 14rpx;
|
|
margin-top: 16rpx;
|
|
}
|
|
|
|
.date-cell {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8rpx;
|
|
height: 56rpx;
|
|
padding: 0 20rpx;
|
|
border-radius: $radius-md;
|
|
background: $color-card;
|
|
font-size: 23rpx;
|
|
color: $color-text-secondary;
|
|
}
|
|
|
|
.date-sep {
|
|
font-size: 22rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.date-clear {
|
|
font-size: 23rpx;
|
|
color: $color-primary;
|
|
}
|
|
|
|
.sum-bar {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin: 6rpx $page-padding-x 16rpx;
|
|
padding: 0 8rpx;
|
|
}
|
|
|
|
.sum-item {
|
|
font-size: 24rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.f-card {
|
|
@include card;
|
|
margin: 0 $page-padding-x 20rpx;
|
|
padding: 24rpx 28rpx;
|
|
|
|
&:active {
|
|
opacity: 0.85;
|
|
}
|
|
}
|
|
|
|
.f-top {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12rpx;
|
|
}
|
|
|
|
.f-partner {
|
|
flex: 1;
|
|
min-width: 0;
|
|
font-size: 29rpx;
|
|
font-weight: 500;
|
|
color: $color-text;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.f-sub {
|
|
display: block;
|
|
margin-top: 8rpx;
|
|
font-size: 23rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.f-amounts {
|
|
display: flex;
|
|
gap: 12rpx;
|
|
margin-top: 18rpx;
|
|
padding-top: 16rpx;
|
|
border-top: 1rpx solid $color-divider;
|
|
}
|
|
|
|
.f-cell {
|
|
flex: 1;
|
|
min-width: 0;
|
|
|
|
.cell-label {
|
|
display: block;
|
|
font-size: 21rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.cell-value {
|
|
display: block;
|
|
margin-top: 6rpx;
|
|
font-size: 26rpx;
|
|
color: $color-text;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
|
|
&.open {
|
|
font-weight: 600;
|
|
color: $color-danger;
|
|
}
|
|
}
|
|
}
|
|
|
|
.f-foot {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-top: 14rpx;
|
|
font-size: 22rpx;
|
|
}
|
|
|
|
.foot-due {
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.foot-over {
|
|
color: $color-danger;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.foot-ok {
|
|
color: #16a34a;
|
|
}
|
|
|
|
.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 {
|
|
font-size: 28rpx;
|
|
color: $color-text-muted;
|
|
}
|
|
|
|
.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>
|