index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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="billNo" label="对账编号" min-width="130" align="center" />
  7. <el-table-column prop="billDate" label="对账日期" min-width="110" align="center">
  8. <template #default="{ row }">{{ parseTime(row.billDate, '{y}-{m}-{d}') }}</template>
  9. </el-table-column>
  10. <el-table-column prop="amount" label="对账单金额" min-width="110" align="center">
  11. <template #default="{ row }">¥{{ row.amount.toFixed(2) }}</template>
  12. </el-table-column>
  13. <el-table-column prop="billStatus" label="对账状态" min-width="90" align="center">
  14. <template #default="{ row }">
  15. {{ getDictLabel(statement_status, row.billStatus) }}
  16. </template>
  17. </el-table-column>
  18. <el-table-column prop="invoiceStatus" label="开票状态" min-width="90" align="center">
  19. <template #default="{ row }">
  20. <span :style="{ color: row.invoiceStatus === '0' ? '#e60012' : '' }">
  21. {{ getDictLabel(invoice_issuance_status, row.invoiceStatus) }}
  22. </span>
  23. </template>
  24. </el-table-column>
  25. <el-table-column prop="payStatus" label="支付状态" min-width="90" align="center">
  26. <template #default="{ row }">
  27. {{ getDictLabel(payment_status, row.payStatus) }}
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="操作" width="100" align="center">
  31. <template #default="{ row }">
  32. <!-- <el-button type="primary" link size="small" @click="handleView(row)">查看</el-button> -->
  33. <el-button type="danger" link size="small" @click="handleConfirm(row)" :disabled="row.billStatus !== '1'">确认</el-button>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <div class="pagination-wrapper">
  38. <TablePagination v-model:page="pagination.page" v-model:pageSize="pagination.pageSize" :total="pagination.total" />
  39. </div>
  40. </div>
  41. </template>
  42. <script setup lang="ts">
  43. import { reactive, ref, onMounted, watch } from 'vue';
  44. import { ElMessage, ElMessageBox } from 'element-plus';
  45. import { PageTitle, SearchBar, TablePagination } from '@/components';
  46. import { getStatementList, confirmStatement } from '@/api/pc/enterprise/statement';
  47. import type { StatementOrder } from '@/api/pc/enterprise/statementTypes';
  48. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  49. const { invoice_issuance_status, statement_status, payment_status } = toRefs<any>(
  50. proxy?.useDict('invoice_issuance_status', 'statement_status', 'payment_status')
  51. );
  52. const searchForm = reactive({
  53. keyword: '', // 对账编号
  54. dateRange: [],
  55. billStatus: '',
  56. invoiceStatus: '',
  57. payStatus: ''
  58. });
  59. const billStatusOptions = ref([{ label: '全部', value: '' }]);
  60. const invoiceStatusOptions = ref([{ label: '全部', value: '' }]);
  61. const payStatusOptions = ref([{ label: '全部', value: '' }]);
  62. // 状态值到文本的映射
  63. const billStatusMap = ref<Record<string, string>>({});
  64. const invoiceStatusMap = ref<Record<string, string>>({});
  65. const payStatusMap = ref<Record<string, string>>({});
  66. const filters = ref([
  67. { field: 'billStatus', label: '对账状态', options: billStatusOptions.value },
  68. { field: 'invoiceStatus', label: '开票状态', options: invoiceStatusOptions.value },
  69. { field: 'payStatus', label: '支付状态', options: payStatusOptions.value }
  70. ]);
  71. const pagination = reactive({ page: 1, pageSize: 5, total: 0 });
  72. const tableData = ref<any[]>([]);
  73. const loading = ref(false);
  74. // 加载对账单列表
  75. const loadStatementList = async () => {
  76. try {
  77. loading.value = true;
  78. const res = await getStatementList({
  79. pageNum: pagination.page,
  80. pageSize: pagination.pageSize,
  81. statementOrderNo: searchForm.keyword,
  82. statementStatus: searchForm.billStatus,
  83. isInvoiceStatus: searchForm.invoiceStatus,
  84. isPaymentStatus: searchForm.payStatus
  85. });
  86. if (res.code === 200 && res.rows) {
  87. tableData.value = res.rows.map((item: StatementOrder) => ({
  88. id: item.id,
  89. billNo: item.statementOrderNo,
  90. billDate: item.statementDate,
  91. amount: parseFloat(item.amount as any) || 0,
  92. billStatus: item.statementStatus,
  93. invoiceStatus: item.isInvoiceStatus,
  94. payStatus: item.isPaymentStatus
  95. }));
  96. pagination.total = res.total || 0;
  97. }
  98. } catch (error) {
  99. console.error('加载对账单列表失败:', error);
  100. ElMessage.error('加载对账单列表失败');
  101. } finally {
  102. loading.value = false;
  103. }
  104. };
  105. // 监听分页变化
  106. watch(
  107. () => [pagination.page, pagination.pageSize],
  108. () => {
  109. loadStatementList();
  110. }
  111. );
  112. // 监听搜索条件变化
  113. watch(
  114. () => [searchForm.keyword, searchForm.billStatus, searchForm.invoiceStatus, searchForm.payStatus],
  115. () => {
  116. pagination.page = 1;
  117. loadStatementList();
  118. }
  119. );
  120. const getDictLabel = (dictOptions: any[], value: string) => {
  121. if (!dictOptions || !value) return value;
  122. const dict = dictOptions.find((item) => item.value === value);
  123. return dict ? dict.label : value;
  124. };
  125. // 加载字典数据
  126. // 页面加载时获取数据
  127. onMounted(() => {
  128. loadStatementList();
  129. });
  130. const handleView = (row: any) => {
  131. ElMessage.info(`查看对账单:${row.billNo}`);
  132. };
  133. const handleConfirm = async (row: any) => {
  134. try {
  135. await ElMessageBox.confirm(`确定要确认对账单"${row.billNo}"吗?`, '提示', {
  136. confirmButtonText: '确定',
  137. cancelButtonText: '取消',
  138. type: 'warning'
  139. });
  140. await confirmStatement({ id: row.id });
  141. row.billStatus = '2';
  142. ElMessage.success('确认成功');
  143. loadStatementList();
  144. } catch (error) {
  145. if (error !== 'cancel') {
  146. console.error('确认对账单失败:', error);
  147. ElMessage.error('确认对账单失败');
  148. }
  149. }
  150. };
  151. </script>
  152. <style scoped>
  153. .pagination-wrapper {
  154. margin-top: 16px;
  155. display: flex;
  156. justify-content: flex-end;
  157. }
  158. </style>