index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="page-container">
  3. <PageTitle title="开票管理" />
  4. <!-- 搜索条件区域 -->
  5. <div class="search-area">
  6. <el-form :model="searchForm" inline>
  7. <el-form-item label="开票编号">
  8. <el-input v-model="searchForm.keyword" placeholder="请输入开票编号" clearable @clear="handleSearch" />
  9. </el-form-item>
  10. <el-form-item label="开票日期">
  11. <el-date-picker
  12. v-model="searchForm.dateRange"
  13. type="daterange"
  14. range-separator="至"
  15. start-placeholder="开始日期"
  16. end-placeholder="结束日期"
  17. value-format="YYYY-MM-DD"
  18. @change="handleSearch"
  19. />
  20. </el-form-item>
  21. <el-form-item label="开票状态">
  22. <el-select v-model="searchForm.invoiceStatus" placeholder="请选择开票状态" clearable @change="handleSearch">
  23. <el-option v-for="item in invoiceStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" @click="handleSearch">搜索</el-button>
  28. <el-button @click="handleReset">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. </div>
  32. <el-table v-loading="loading" :data="tableData" border style="width: 100%">
  33. <el-table-column prop="statementInvoiceNo" label="开票编号" min-width="130" align="center" />
  34. <el-table-column prop="invoiceTime" label="开票时间" min-width="110" align="center">
  35. <template #default="scope">
  36. <span>{{ parseTime(scope.row.invoiceTime, '{y}-{m}-{d}') }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="customerName" label="客户名称" min-width="110" align="center" />
  40. <el-table-column prop="amount" label="开票金额" min-width="110" align="center">
  41. <template #default="{ row }">¥{{ row.amount.toFixed(2) }}</template>
  42. </el-table-column>
  43. <el-table-column prop="invoiceStatus" label="开票状态" min-width="90" align="center">
  44. <template #default="{ row }">
  45. {{ getDictLabel(invoice_status, row.invoiceStatus) }}
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" width="100" align="center">
  49. <template #default="{ row }">
  50. <el-button type="primary" link size="small" @click="handleView(row)">查看</el-button>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <div class="pagination-wrapper">
  55. <TablePagination v-model:page="pagination.page" v-model:pageSize="pagination.pageSize" :total="pagination.total" />
  56. </div>
  57. </div>
  58. </template>
  59. <script setup lang="ts">
  60. import { reactive, ref, onMounted, watch, computed, getCurrentInstance, toRefs } from 'vue';
  61. import { ElMessage, ElMessageBox } from 'element-plus';
  62. import { useRouter } from 'vue-router';
  63. import { PageTitle, TablePagination } from '@/components';
  64. import { getStatementInvoiceList } from '@/api/pc/enterprise/statement';
  65. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  66. const { invoice_issuance_status, invoice_status } = toRefs<any>(proxy?.useDict('invoice_issuance_status', 'invoice_status'));
  67. // const { invoice_status } = toRefs<any>(proxy?.useDict('invoice_issuance_status', 'statement_status', 'invoice_status'));
  68. const searchForm = reactive({
  69. keyword: '',
  70. dateRange: [],
  71. invoiceStatus: ''
  72. });
  73. const form = reactive({
  74. statementOrderIds: []
  75. });
  76. // 从字典生成选项,添加"全部"选项
  77. const invoiceStatusOptions = computed(() => [{ label: '全部', value: '' }, ...(invoice_status.value || [])]);
  78. const pagination = reactive({ page: 1, pageSize: 5, total: 0 });
  79. const tableData = ref<any[]>([]);
  80. const loading = ref(false);
  81. const router = useRouter();
  82. // 加载开票列表
  83. const loadStatementInvoice = async () => {
  84. try {
  85. loading.value = true;
  86. const queryParams = {
  87. pageNum: pagination.page,
  88. pageSize: pagination.pageSize,
  89. statementInvoiceNo: searchForm.keyword,
  90. invoiceStatus: searchForm.invoiceStatus,
  91. params: {} as any
  92. };
  93. // 添加日期范围参数
  94. if (searchForm.dateRange && searchForm.dateRange.length === 2) {
  95. queryParams.params.beginTime = searchForm.dateRange[0];
  96. queryParams.params.endTime = searchForm.dateRange[1];
  97. }
  98. const res = await getStatementInvoiceList(queryParams);
  99. if (res.code === 200 && res.rows) {
  100. tableData.value = res.rows.map((item: any) => ({
  101. id: item.id,
  102. statementInvoiceNo: item.statementInvoiceNo,
  103. invoiceTime: item.invoiceTime,
  104. customerName: item.customerName,
  105. amount: parseFloat(item.invoiceAmount as any) || 0,
  106. invoiceStatus: item.invoiceStatus,
  107. payStatus: item.isPaymentStatus
  108. }));
  109. pagination.total = res.total || 0;
  110. }
  111. } catch (error) {
  112. console.error('加载对账单列表失败:', error);
  113. ElMessage.error('加载对账单列表失败');
  114. } finally {
  115. loading.value = false;
  116. }
  117. };
  118. const getDictLabel = (dictOptions: any[], value: string) => {
  119. if (!dictOptions || !value) return value;
  120. const dict = dictOptions.find((item) => item.value === value);
  121. return dict ? dict.label : value;
  122. };
  123. // 监听分页变化
  124. watch(
  125. () => [pagination.page, pagination.pageSize],
  126. () => {
  127. loadStatementInvoice();
  128. }
  129. );
  130. // 监听搜索条件变化
  131. watch(
  132. () => [searchForm.keyword, searchForm.dateRange, searchForm.invoiceStatus],
  133. () => {
  134. pagination.page = 1;
  135. loadStatementInvoice();
  136. }
  137. );
  138. // 搜索
  139. const handleSearch = () => {
  140. pagination.page = 1;
  141. loadStatementInvoice();
  142. };
  143. // 重置
  144. const handleReset = () => {
  145. searchForm.keyword = '';
  146. searchForm.dateRange = [];
  147. searchForm.invoiceStatus = '';
  148. pagination.page = 1;
  149. loadStatementInvoice();
  150. };
  151. // 页面加载时获取数据
  152. onMounted(() => {
  153. // loadDictData();
  154. loadStatementInvoice();
  155. });
  156. const handleView = (row: any) => {
  157. router.push(`/reconciliation/invoiceManage/detail?id=${row.id}`);
  158. };
  159. </script>
  160. <style scoped>
  161. .search-area {
  162. margin-bottom: 16px;
  163. padding: 16px;
  164. background: #fff;
  165. border: 1px solid #e4e7ed;
  166. border-radius: 4px;
  167. }
  168. .search-area .el-form {
  169. display: flex;
  170. flex-wrap: wrap;
  171. gap: 16px;
  172. align-items: flex-end;
  173. }
  174. .search-area .el-form-item {
  175. margin-bottom: 0;
  176. margin-right: 0;
  177. }
  178. .search-area .el-input,
  179. .search-area .el-select,
  180. .search-area .el-date-picker {
  181. width: 200px;
  182. }
  183. .pagination-wrapper {
  184. margin-top: 16px;
  185. display: flex;
  186. justify-content: flex-end;
  187. }
  188. </style>