完善开票记录页面功能

This commit is contained in:
Wei_佳 2025-11-13 17:52:45 +08:00
parent 92aed53158
commit bf88fb502b

View File

@ -15,6 +15,7 @@ import CommonPage from '@/components/page/CommonPage.vue'
import QueryBarItem from '@/components/query-bar/QueryBarItem.vue' import QueryBarItem from '@/components/query-bar/QueryBarItem.vue'
import CrudModal from '@/components/table/CrudModal.vue' import CrudModal from '@/components/table/CrudModal.vue'
import CrudTable from '@/components/table/CrudTable.vue' import CrudTable from '@/components/table/CrudTable.vue'
import InvoiceModal from './InvoiceModal.vue'
import { formatDate, renderIcon } from '@/utils' import { formatDate, renderIcon } from '@/utils'
import { useCRUD } from '@/composables' import { useCRUD } from '@/composables'
@ -27,6 +28,11 @@ const $table = ref(null)
const queryItems = ref({}) const queryItems = ref({})
const vPermission = resolveDirective('permission') const vPermission = resolveDirective('permission')
// /
const invoiceModalVisible = ref(false)
const invoiceModalMode = ref('invoice') // 'invoice' 'view'
const currentInvoice = ref(null)
// //
const statusOptions = [ const statusOptions = [
{ label: '全部', value: '' }, { label: '全部', value: '' },
@ -212,25 +218,15 @@ const columns = [
// - // -
row.status === 'pending' && row.status === 'pending' &&
h( h(
NPopconfirm, NButton,
{ {
onPositiveClick: () => handleUpdateStatus(row, 'invoiced'), size: 'small',
type: 'success',
style: 'margin-right: 8px;',
onClick: () => handleInvoice(row),
}, },
{ {
trigger: () => default: () => '开票',
h(
NButton,
{
size: 'small',
type: 'success',
style: 'margin-right: 8px;',
},
{
default: () => '开票',
// icon: renderIcon('mdi:receipt-text-outline', { size: 16 }),
}
),
default: () => h('div', {}, '确认开票?'),
} }
), ),
// 退 - // 退 -
@ -251,7 +247,6 @@ const columns = [
}, },
{ {
default: () => '退款', default: () => '退款',
// icon: renderIcon('mdi:cash-refund', { size: 16 }),
} }
), ),
default: () => h('div', {}, '确认退款?'), default: () => h('div', {}, '确认退款?'),
@ -269,7 +264,6 @@ const columns = [
}, },
{ {
default: () => '查看', default: () => '查看',
// icon: renderIcon('mdi:eye-outline', { size: 16 }),
} }
), ),
] ]
@ -305,14 +299,38 @@ async function handleRefund(row) {
} }
} }
//
function handleInvoice(row) {
currentInvoice.value = row
invoiceModalMode.value = 'invoice'
invoiceModalVisible.value = true
}
// //
function handleView(row) { function handleView(row) {
// currentInvoice.value = row
$message.info(`查看开票记录详情 - ID: ${row.id}`) invoiceModalMode.value = 'view'
// invoiceModalVisible.value = true
// modalVisible.value = true }
// modalAction.value = 'view'
// modalForm.value = { ...row } // /
async function handleInvoiceConfirm(data) {
try {
if (invoiceModalMode.value === 'invoice') {
//
await api.sendInvoice(data)
await api.updateInvoiceStatus({ id: data.id, status: 'invoiced' })
$message.success('开票成功')
} else {
//
await api.sendInvoice(data)
$message.success('发送成功')
}
invoiceModalVisible.value = false
$table.value?.handleSearch()
} catch (error) {
$message.error('操作失败: ' + error.message)
}
} }
const validateForm = { const validateForm = {
@ -473,5 +491,13 @@ const validateForm = {
</NFormItem> </NFormItem>
</NForm> </NForm>
</CrudModal> </CrudModal>
<!-- 开票/查看弹窗 -->
<InvoiceModal
v-model:visible="invoiceModalVisible"
:invoice-data="currentInvoice"
:mode="invoiceModalMode"
@confirm="handleInvoiceConfirm"
/>
</CommonPage> </CommonPage>
</template> </template>