index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="page-container">
  3. <PageTitle title="开票管理" />
  4. <SearchBar :form="searchForm" :filters="filters" placeholder="开票编号" />
  5. <el-table v-loading="loading" :data="tableData" border style="width: 100%">
  6. <el-table-column prop="statementInvoiceNo" label="开票编号" min-width="130" align="center" />
  7. <el-table-column prop="invoiceTime" label="开票时间" min-width="110" align="center">
  8. <template #default="scope">
  9. <span>{{ parseTime(scope.row.invoiceTime, '{y}-{m}-{d}') }}</span>
  10. </template>
  11. </el-table-column>
  12. <el-table-column prop="customerName" label="客户名称" min-width="110" align="center" />
  13. <el-table-column prop="amount" label="开票金额" min-width="110" align="center">
  14. <template #default="{ row }">¥{{ row.amount.toFixed(2) }}</template>
  15. </el-table-column>
  16. <el-table-column prop="invoiceStatus" label="开票状态" min-width="90" align="center">
  17. <template #default="{ row }">
  18. {{ getDictLabel(invoice_status, row.invoiceStatus) }}
  19. </template>
  20. </el-table-column>
  21. <el-table-column label="操作" width="100" align="center">
  22. <template #default="{ row }">
  23. <el-button type="primary" link size="small" @click="handleView(row)">查看</el-button>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <div class="pagination-wrapper">
  28. <TablePagination v-model:page="pagination.page" v-model:pageSize="pagination.pageSize" :total="pagination.total" />
  29. </div>
  30. </div>
  31. </template>
  32. <script setup lang="ts">
  33. import { reactive, ref, computed, onMounted, watch } from 'vue';
  34. import { ElMessage, ElMessageBox } from 'element-plus';
  35. import { useRouter } from 'vue-router';
  36. import { PageTitle, SearchBar, TablePagination } from '@/components';
  37. import { getStatementInvoiceList } from '@/api/pc/enterprise/statement';
  38. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  39. const { invoice_status } = toRefs<any>(proxy?.useDict('invoice_issuance_status', 'statement_status', 'invoice_status'));
  40. const searchForm = reactive({
  41. keyword: '',
  42. dateRange: [],
  43. invoiceStatus: ''
  44. });
  45. const form = reactive({
  46. statementOrderIds: []
  47. });
  48. const invoiceStatusOptions = ref([{ label: '全部', value: '' }]);
  49. const filters = ref([{ field: 'invoiceStatus', label: '开票状态', options: invoiceStatusOptions.value }]);
  50. const pagination = reactive({ page: 1, pageSize: 5, total: 0 });
  51. const tableData = ref<any[]>([]);
  52. const loading = ref(false);
  53. const router = useRouter();
  54. // 加载对账单列表
  55. const loadStatementInvoice = async () => {
  56. try {
  57. loading.value = true;
  58. const res = await getStatementInvoiceList({
  59. pageNum: pagination.page,
  60. pageSize: pagination.pageSize,
  61. statementInvoiceNo: searchForm.keyword,
  62. isInvoiceStatus: searchForm.invoiceStatus
  63. });
  64. if (res.code === 200 && res.rows) {
  65. tableData.value = res.rows.map((item: any) => ({
  66. id: item.id,
  67. statementInvoiceNo: item.statementInvoiceNo,
  68. invoiceTime: item.invoiceTime,
  69. customerName: item.customerName,
  70. amount: parseFloat(item.invoiceAmount as any) || 0,
  71. invoiceStatus: item.invoiceStatus,
  72. payStatus: item.isPaymentStatus
  73. }));
  74. pagination.total = res.total || 0;
  75. }
  76. } catch (error) {
  77. console.error('加载对账单列表失败:', error);
  78. ElMessage.error('加载对账单列表失败');
  79. } finally {
  80. loading.value = false;
  81. }
  82. };
  83. const getDictLabel = (dictOptions: any[], value: string) => {
  84. if (!dictOptions || !value) return value;
  85. const dict = dictOptions.find((item) => item.value === value);
  86. return dict ? dict.label : value;
  87. };
  88. // 监听分页变化
  89. watch(
  90. () => [pagination.page, pagination.pageSize],
  91. () => {
  92. loadStatementInvoice();
  93. }
  94. );
  95. // 监听搜索条件变化
  96. watch(
  97. () => [searchForm.keyword, searchForm.invoiceStatus],
  98. () => {
  99. pagination.page = 1;
  100. loadStatementInvoice();
  101. }
  102. );
  103. // 页面加载时获取数据
  104. onMounted(() => {
  105. // loadDictData();
  106. loadStatementInvoice();
  107. });
  108. const handleView = (row: any) => {
  109. router.push(`/reconciliation/invoiceManage/detail?id=${row.id}`);
  110. };
  111. </script>
  112. <style scoped>
  113. .bottom-bar {
  114. margin-top: 16px;
  115. padding: 16px;
  116. background: #fafafa;
  117. border: 1px solid #eee;
  118. border-radius: 4px;
  119. display: flex;
  120. justify-content: flex-end;
  121. }
  122. .summary {
  123. display: flex;
  124. align-items: center;
  125. gap: 20px;
  126. }
  127. .summary span {
  128. font-size: 14px;
  129. color: #666;
  130. }
  131. .summary em {
  132. color: #e60012;
  133. font-style: normal;
  134. font-weight: bold;
  135. }
  136. .summary .total em {
  137. font-size: 16px;
  138. }
  139. .pagination-wrapper {
  140. margin-top: 16px;
  141. display: flex;
  142. justify-content: flex-end;
  143. }
  144. </style>