subsidy-management.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import { Component } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. import { RouterModule } from '@angular/router';
  4. import { FormsModule } from '@angular/forms';
  5. interface SubsidyApplication {
  6. id: string;
  7. enterpriseName: string;
  8. type: string;
  9. amount: number;
  10. applyDate: string;
  11. status: 'pending' | 'approved' | 'rejected';
  12. blockchainStatus: 'verified' | 'verifying' | 'failed';
  13. }
  14. interface PaymentRecord {
  15. id: string;
  16. enterpriseName: string;
  17. amount: number;
  18. date: string;
  19. purpose: string;
  20. effectiveness: number;
  21. }
  22. @Component({
  23. selector: 'app-subsidy-management',
  24. standalone: true,
  25. imports: [CommonModule, RouterModule, FormsModule],
  26. templateUrl: './subsidy-management.html',
  27. styleUrl: './subsidy-management.scss'
  28. })
  29. export class SubsidyManagement {
  30. activeTab: 'applications' | 'payments' | 'evaluation' = 'applications';
  31. filterStatus: 'all' | 'pending' | 'approved' | 'rejected' = 'all';
  32. selectedApplication: SubsidyApplication | null = null;
  33. selectedPayment: PaymentRecord | null = null;
  34. showDetailModal = false;
  35. showPaymentModal = false;
  36. applications: SubsidyApplication[] = [
  37. {
  38. id: 'SUB-2023-001',
  39. enterpriseName: '智回环保科技有限公司',
  40. type: '回收设备补贴',
  41. amount: 50000,
  42. applyDate: '2023-05-20',
  43. status: 'pending',
  44. blockchainStatus: 'verified'
  45. },
  46. {
  47. id: 'SUB-2023-002',
  48. enterpriseName: '绿色循环资源公司',
  49. type: '环保技术补贴',
  50. amount: 80000,
  51. applyDate: '2023-05-19',
  52. status: 'pending',
  53. blockchainStatus: 'verifying'
  54. },
  55. {
  56. id: 'SUB-2023-003',
  57. enterpriseName: '城市再生资源中心',
  58. type: '运营补贴',
  59. amount: 120000,
  60. applyDate: '2023-05-18',
  61. status: 'approved',
  62. blockchainStatus: 'verified'
  63. },
  64. {
  65. id: 'SUB-2023-004',
  66. enterpriseName: '环保回收企业',
  67. type: '设备采购补贴',
  68. amount: 30000,
  69. applyDate: '2023-05-17',
  70. status: 'rejected',
  71. blockchainStatus: 'failed'
  72. }
  73. ];
  74. payments: PaymentRecord[] = [
  75. {
  76. id: 'PAY-001',
  77. enterpriseName: '城市再生资源中心',
  78. amount: 120000,
  79. date: '2023-05-15',
  80. purpose: '运营补贴',
  81. effectiveness: 92
  82. },
  83. {
  84. id: 'PAY-002',
  85. enterpriseName: '绿色循环资源公司',
  86. amount: 60000,
  87. date: '2023-05-10',
  88. purpose: '技术升级',
  89. effectiveness: 88
  90. }
  91. ];
  92. get filteredApplications(): SubsidyApplication[] {
  93. if (this.filterStatus === 'all') {
  94. return this.applications;
  95. }
  96. return this.applications.filter(app => app.status === this.filterStatus);
  97. }
  98. get stats() {
  99. return {
  100. pending: this.applications.filter(a => a.status === 'pending').length,
  101. approved: this.applications.filter(a => a.status === 'approved').length,
  102. rejected: this.applications.filter(a => a.status === 'rejected').length,
  103. totalAmount: this.payments.reduce((sum, p) => sum + p.amount, 0)
  104. };
  105. }
  106. switchTab(tab: 'applications' | 'payments' | 'evaluation'): void {
  107. this.activeTab = tab;
  108. }
  109. setFilter(status: 'all' | 'pending' | 'approved' | 'rejected'): void {
  110. this.filterStatus = status;
  111. }
  112. getStatusText(status: string): string {
  113. const statusMap: {[key: string]: string} = {
  114. 'pending': '待审核',
  115. 'approved': '已通过',
  116. 'rejected': '已驳回',
  117. 'verified': '已验证',
  118. 'verifying': '验证中',
  119. 'failed': '验证失败'
  120. };
  121. return statusMap[status] || status;
  122. }
  123. getStatusClass(status: string): string {
  124. return `status-${status}`;
  125. }
  126. viewApplicationDetail(application: SubsidyApplication): void {
  127. this.selectedApplication = application;
  128. this.showDetailModal = true;
  129. }
  130. closeDetail(): void {
  131. this.showDetailModal = false;
  132. this.selectedApplication = null;
  133. }
  134. approveApplication(application: SubsidyApplication, event?: Event): void {
  135. if (event) event.stopPropagation();
  136. if (confirm(`确定通过 ${application.enterpriseName} 的补贴申请吗?`)) {
  137. application.status = 'approved';
  138. alert('申请已通过');
  139. }
  140. }
  141. rejectApplication(application: SubsidyApplication, event?: Event): void {
  142. if (event) event.stopPropagation();
  143. const reason = prompt('请输入驳回原因:');
  144. if (reason) {
  145. application.status = 'rejected';
  146. alert('申请已驳回');
  147. }
  148. }
  149. viewPaymentDetail(payment: PaymentRecord): void {
  150. this.selectedPayment = payment;
  151. this.showPaymentModal = true;
  152. }
  153. closePaymentDetail(): void {
  154. this.showPaymentModal = false;
  155. this.selectedPayment = null;
  156. }
  157. exportPaymentReport(payment: PaymentRecord): void {
  158. alert(`导出 ${payment.enterpriseName} 的付款报告`);
  159. }
  160. verifyBlockchain(application: SubsidyApplication): void {
  161. application.blockchainStatus = 'verifying';
  162. setTimeout(() => {
  163. application.blockchainStatus = 'verified';
  164. alert('区块链验证完成');
  165. }, 1500);
  166. }
  167. constructor() {}
  168. }