You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
6.5 KiB

  1. <template>
  2. <div>
  3. <el-row :gutter="20">
  4. <el-col :span="6">
  5. <el-card @click.native="navigateToMes('unfinishedProjects',counts)" class="card-item">
  6. <div class="card-title">我参与的未结项目</div>
  7. <div class="card-count">{{ counts.unfinishedProjectsCount }}</div>
  8. </el-card>
  9. </el-col>
  10. <el-col :span="6">
  11. <el-card @click.native="navigateToMes('pendingUploads',counts)" class="card-item">
  12. <div class="card-title">待上传文件</div>
  13. <div class="card-count">{{ counts.pendingUploadsCount }}</div>
  14. </el-card>
  15. </el-col>
  16. <el-col :span="6">
  17. <el-card @click.native="navigateToMes('pendingConfirmations',counts)" class="card-item">
  18. <div class="card-title">待生产确认的项目</div>
  19. <div class="card-count">{{ counts.pendingConfirmationsCount }}</div>
  20. </el-card>
  21. </el-col>
  22. </el-row>
  23. <el-row :gutter="20" style="margin-top: 10px;">
  24. <el-col :span="6">
  25. <el-card @click.native="navigateToMes('allProjects',counts)" class="card-item">
  26. <div class="card-title">我参与的所有项目</div>
  27. <div class="card-count">{{ counts.allProjectsCount }}</div>
  28. </el-card>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-card @click.native="navigateToMes('overdueUploads',counts)" class="card-item">
  32. <div class="card-title">逾期的待上传文件</div>
  33. <div class="card-count">{{ counts.overdueUploadsCount }}</div>
  34. </el-card>
  35. </el-col>
  36. <el-col :span="6">
  37. <el-card @click.native="navigateToMes('overdueConfirmations',counts)" class="card-item">
  38. <div class="card-title">逾期的待生产确认的项目</div>
  39. <div class="card-count">{{ counts.overdueConfirmationsCount }}</div>
  40. </el-card>
  41. </el-col>
  42. </el-row>
  43. </div>
  44. </template>
  45. <script>
  46. import { agencyMatter } from "../../../api/eam/eamProject";
  47. export default {
  48. data() {
  49. return {
  50. counts: {
  51. unfinishedProjectsCount: 0,
  52. allProjectsCount: 0,
  53. pendingUploadsCount: 0,
  54. overdueUploadsCount: 0,
  55. pendingConfirmationsCount: 0,
  56. overdueConfirmationsCount: 0,
  57. unfinishedProjects: [],
  58. allProjects: [],
  59. pendingUploads: [],
  60. overdueUploads: [],
  61. pendingConfirmations: [],
  62. overdueConfirmations: [],
  63. },
  64. intervalId: null,
  65. };
  66. },
  67. created() {
  68. this.fetchCounts();
  69. this.startAutoRefresh();
  70. },
  71. beforeDestroy() {
  72. this.stopAutoRefresh();
  73. },
  74. methods: {
  75. fetchCounts() {
  76. agencyMatter()
  77. .then(({ data }) => {
  78. this.counts = data;
  79. this.counts.unfinishedProjectsCount = this.counts.unfinishedProjects.length;
  80. this.counts.allProjectsCount = this.counts.allProjects.length;
  81. this.counts.pendingUploadsCount = this.counts.pendingUploads.length;
  82. this.counts.overdueUploadsCount = this.counts.overdueUploads.length;
  83. this.counts.pendingConfirmationsCount = this.counts.pendingConfirmations.length;
  84. this.counts.overdueConfirmationsCount = this.counts.overdueConfirmations.length;
  85. })
  86. .catch((error) => {
  87. console.error("Error fetching project counts:", error);
  88. });
  89. },
  90. navigateToMes(path, row) {
  91. let projectIds = '';
  92. if (path === 'unfinishedProjects') {
  93. for (let i = 0; i < row.unfinishedProjects.length; i++) {
  94. // 使用逗号拼接 unfinishedProjects.projectId,如果是最后一个则不加逗号
  95. projectIds += row.unfinishedProjects[i].projectId + (i === row.unfinishedProjects.length - 1 ? '' : ',');
  96. }
  97. this.$router.push({ path: 'eam-eamProjectInfo', query: { projectId: projectIds } });
  98. }
  99. else if (path === 'allProjects') {
  100. for (let i = 0; i < row.allProjects.length; i++) {
  101. projectIds += row.allProjects[i].projectId + (i === row.allProjects.length - 1 ? '' : ',');
  102. }
  103. this.$router.push({ path: 'eam-eamProjectInfo', query: { projectId: projectIds } });
  104. }
  105. else if (path === 'pendingUploads') {
  106. for (let i = 0; i < row.pendingUploads.length; i++) {
  107. projectIds += row.pendingUploads[i].projectId + (i === row.pendingUploads.length - 1 ? '' : ',');
  108. }
  109. this.$router.push({ name: 'eam-eamProjectInfoForUploads', query: { projectId: projectIds,flag:'1' } });
  110. }
  111. else if (path === 'overdueUploads') {
  112. for (let i = 0; i < row.overdueUploads.length; i++) {
  113. projectIds += row.overdueUploads[i].projectId + (i === row.overdueUploads.length - 1 ? '' : ',');
  114. }
  115. this.$router.push({ path: 'eam-eamProjectInfoForUploads', query: { projectId: projectIds,flag:'2' } });
  116. }
  117. else if (path === 'pendingConfirmations') {
  118. for (let i = 0; i < row.pendingConfirmations.length; i++) {
  119. projectIds += row.pendingConfirmations[i].projectId + (i === row.pendingConfirmations.length - 1 ? '' : ',');
  120. }
  121. this.$router.push({ path: 'eam-eamProjectInfoForConfirm', query: { projectId: projectIds,flag:'3' } });
  122. }
  123. else if (path === 'overdueConfirmations') {
  124. for (let i = 0; i < row.overdueConfirmations.length; i++) {
  125. projectIds += row.overdueConfirmations[i].projectId + (i === row.overdueConfirmations.length - 1 ? '' : ',');
  126. }
  127. this.$router.push({ path: 'eam-eamProjectInfoForConfirm', query: { projectId: projectIds,flag:'4' } });
  128. }
  129. },
  130. startAutoRefresh() {
  131. this.intervalId = setInterval(() => {
  132. this.fetchCounts();
  133. }, 20000); // 每20秒刷新一次
  134. },
  135. stopAutoRefresh() {
  136. if (this.intervalId) {
  137. clearInterval(this.intervalId);
  138. }
  139. },
  140. },
  141. };
  142. </script>
  143. <style scoped>
  144. .card-item {
  145. cursor: pointer;
  146. margin-bottom: 20px;
  147. transition: transform 0.3s, box-shadow 0.3s;
  148. overflow: hidden;
  149. //padding: 10px;
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: space-between;
  153. align-items: center;
  154. height: 208px;
  155. width: 230px;
  156. margin-left: 40px;
  157. margin-top: 10px;
  158. }
  159. .card-item:hover {
  160. transform: translateY(-5px);
  161. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  162. }
  163. .card-title {
  164. font-size: 18px;
  165. font-weight: bold;
  166. margin-bottom: 10px;
  167. margin-top: 20px;
  168. }
  169. .card-count {
  170. font-size: 55px;
  171. color: #17B3A3;
  172. text-align: center;
  173. font-weight: bold;
  174. margin-top: 50px;
  175. }
  176. .project-list {
  177. font-size: 12px;
  178. color: #333;
  179. line-height: 1.5;
  180. margin-bottom: 5px;
  181. }
  182. .el-divider {
  183. margin: 10px 0;
  184. }
  185. </style>