Merge branch 'test-caojia' into test

This commit is contained in:
caojia
2026-11-20 13:45:08 +08:00
14 changed files with 427 additions and 69 deletions
+4
View File
@@ -29,6 +29,10 @@ export function getDefaultArBankAccount(currency = 'CNY') {
return request({ url: '/ar/bill/default-bank-account', method: 'get', params: { currency } })
}
export function listArBillBankAccountOptions(currency = 'CNY') {
return request({ url: '/ar/bill/bank-account-options', method: 'get', params: { currency } })
}
export function generateArBill(data) {
return request({ url: '/ar/bill/generate', method: 'post', data, timeout: 30000 })
}
@@ -60,6 +60,7 @@
<el-table-column prop="totalAmount" label="订单金额" width="120" align="right"><template #default="{ row }">{{ money(row.totalAmount) }}</template></el-table-column>
<el-table-column prop="productAmount" label="整单产品价" width="130" align="right"><template #default="{ row }">{{ amount4(row.productAmount) }}</template></el-table-column>
<el-table-column prop="redlineAmount" label="整单红线价" width="130" align="right"><template #default="{ row }">{{ amount4(row.redlineAmount) }}</template></el-table-column>
<el-table-column prop="receiveTime" label="收货时间" width="170"><template #default="{ row }">{{ row.receiveTime || '-' }}</template></el-table-column>
</el-table>
<el-pagination
v-if="detailTotal > 0 || appliedDetailQuery.orderKeyword || appliedDetailQuery.productKeyword"
@@ -32,13 +32,16 @@
</el-row>
</el-form>
<div class="payee-card" v-loading="bankAccountLoading">
<div class="payee-title">收款方信息(按币种自动匹配)</div>
<div class="payee-title">收款方信息</div>
<el-select v-model="selectedBankAccountId" class="payee-select" placeholder="请选择收款账户" :disabled="bankAccountLoading || generateLoading" @change="handleBankAccountChange">
<el-option v-for="account in bankAccounts" :key="account.bankAccountId" :value="String(account.bankAccountId)" :label="`${account.accountName}(${account.accountNo})`" />
</el-select>
<template v-if="bankAccount">
<span><b>开户名:</b>{{ bankAccount.accountName }}</span>
<span><b>开户行:</b>{{ bankAccount.bankName }}</span>
<span><b>账号:</b>{{ bankAccount.accountNo }}</span>
</template>
<span v-else class="payee-empty">当前币种尚未配置公司默认收款账户</span>
<span v-else-if="!bankAccountLoading" class="payee-empty">当前币种尚未配置启用的收款账户</span>
</div>
<div class="preview-toolbar">
<span v-if="previewSearched" class="preview-summary">
@@ -177,7 +180,7 @@
</template>
<script setup name="GenerateBillDialog">
import { listArBillGenerateCustomerOptions, getDefaultArBankAccount, previewArBill, getArBillPreviewAmount, previewExcludedArBill, generateArBill } from '@/api/ar/bill'
import { listArBillGenerateCustomerOptions, listArBillBankAccountOptions, previewArBill, getArBillPreviewAmount, previewExcludedArBill, generateArBill } from '@/api/ar/bill'
import { Download, Refresh, Search, Select } from '@element-plus/icons-vue'
import { AR_BILL_SELECTION_MODE } from '@/constants/ar/enums'
import { exportAsync } from '@/utils/excelExport'
@@ -255,7 +258,10 @@ let excludeRequestSeq = 0
const previewQuery = ref(null)
let syncingPageSelection = false
const bankAccountLoading = ref(false)
const bankAccount = ref(null)
const bankAccounts = ref([])
const selectedBankAccountId = ref('')
const bankAccount = computed(() => bankAccounts.value.find(account => String(account.bankAccountId) === selectedBankAccountId.value) || null)
let bankAccountRequestSeq = 0
const generateRequestId = ref('')
const generateFormRef = ref()
const billNameFormRef = ref()
@@ -288,8 +294,7 @@ function openGenerate() {
Object.assign(billNameForm, { billName: '' })
billNameOpen.value = false
resetPreview()
bankAccount.value = null
loadDefaultBankAccount()
loadBankAccounts()
nextTick(() => generateFormRef.value?.clearValidate())
}
@@ -301,7 +306,7 @@ function handleCustomerChange(_, item) {
function handleCurrencyChange() {
resetPreview()
loadDefaultBankAccount()
loadBankAccounts()
}
// 只清空输入内容,不自动刷新预览;用户点击“查询”后再按新条件查询。
@@ -315,16 +320,25 @@ function clearExcludeIdentifiers() {
invalidateExcludeSearch()
}
function loadDefaultBankAccount() {
function loadBankAccounts() {
const requestSeq = ++bankAccountRequestSeq
bankAccountLoading.value = true
bankAccount.value = null
getDefaultArBankAccount(generateForm.currency).then(res => {
bankAccount.value = res.data || null
bankAccounts.value = []
selectedBankAccountId.value = ''
listArBillBankAccountOptions(generateForm.currency).then(res => {
if (requestSeq !== bankAccountRequestSeq) return
bankAccounts.value = res.data || []
const defaultAccount = bankAccounts.value.find(account => String(account.isDefault) === '1') || bankAccounts.value[0]
selectedBankAccountId.value = defaultAccount ? String(defaultAccount.bankAccountId) : ''
}).finally(() => {
bankAccountLoading.value = false
if (requestSeq === bankAccountRequestSeq) bankAccountLoading.value = false
})
}
function handleBankAccountChange() {
if (!generateLoading.value) generateRequestId.value = ''
}
// 条件变化后清理预览和跨页选中状态;用户点击查询时重新加载第一页。
function resetPreview() {
previewRows.value = []
@@ -363,6 +377,7 @@ function buildGenerateRequest(requestId) {
return {
...(previewQuery.value || buildGenerateQuery()),
billName: billNameForm.billName.trim(),
bankAccountId: selectedBankAccountId.value,
selectionMode: selectionMode.value,
sourceBillIds: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED ? [] : selectedRows.value.map(row => String(row.billId)),
excludedSourceBillIds: [],
@@ -673,6 +688,7 @@ function createRequestId() { return globalThis.crypto?.randomUUID?.() || `ar-${D
.order-identifier-clear { position: absolute; top: 4px; right: 6px; z-index: 1; padding: 2px 4px; }
.payee-card { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; min-height: 42px; margin: 4px 0 12px; padding: 9px 12px; border: 1px solid var(--el-border-color-lighter); border-radius: 4px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); font-size: 13px; }
.payee-title { color: var(--el-text-color-primary); font-weight: 600; }
.payee-select { width: 340px; max-width: 100%; }
.payee-empty { color: var(--el-color-danger); }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 10px; padding: 10px 14px; border-radius: 6px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); }
.preview-summary { flex: 1; font-size: 14px; }