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.

200 lines
7.3 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 projectNos = '';
  92. let testPartNos = '';
  93. if (path === 'unfinishedProjects') {
  94. for (let i = 0; i < row.unfinishedProjects.length; i++) {
  95. // 使用逗号拼接 unfinishedProjects.projectNo,如果是最后一个则不加逗号
  96. projectNos += row.unfinishedProjects[i].projectNo + (i === row.unfinishedProjects.length - 1 ? '' : ',');
  97. testPartNos += row.unfinishedProjects[i].testPartNo + (i === row.unfinishedProjects.length - 1 ? '' : ',');
  98. }
  99. this.$router.push({ path: 'eam-eamProjectPartInfo', query: { projectNo: projectNos,testPartNo: testPartNos} });
  100. }
  101. else if (path === 'allProjects') {
  102. for (let i = 0; i < row.allProjects.length; i++) {
  103. projectNos += row.allProjects[i].projectNo + (i === row.allProjects.length - 1 ? '' : ',');
  104. testPartNos += row.allProjects[i].testPartNo + (i === row.allProjects.length - 1 ? '' : ',');
  105. }
  106. this.$router.push({ path: 'eam-eamProjectPartInfo', query: { projectNo: projectNos,testPartNo: testPartNos } });
  107. }
  108. else if (path === 'pendingUploads') {
  109. for (let i = 0; i < row.pendingUploads.length; i++) {
  110. projectNos += row.pendingUploads[i].projectNo + (i === row.pendingUploads.length - 1 ? '' : ',');
  111. testPartNos += row.pendingUploads[i].testPartNo + (i === row.pendingUploads.length - 1 ? '' : ',');
  112. }
  113. this.$router.push({ name: 'eam-eamProjectInfoForUploads', query: { projectNo: projectNos,flag:'1',testPartNo: testPartNos } });
  114. }
  115. else if (path === 'overdueUploads') {
  116. for (let i = 0; i < row.overdueUploads.length; i++) {
  117. projectNos += row.overdueUploads[i].projectNo + (i === row.overdueUploads.length - 1 ? '' : ',');
  118. testPartNos += row.overdueUploads[i].testPartNo + (i === row.overdueUploads.length - 1 ? '' : ',');
  119. }
  120. this.$router.push({ path: 'eam-eamProjectInfoForUploads', query: { projectNo: projectNos,flag:'2',testPartNo: testPartNos } });
  121. }
  122. else if (path === 'pendingConfirmations') {
  123. for (let i = 0; i < row.pendingConfirmations.length; i++) {
  124. projectNos += row.pendingConfirmations[i].projectNo + (i === row.pendingConfirmations.length - 1 ? '' : ',');
  125. testPartNos += row.pendingConfirmations[i].testPartNo + (i === row.pendingConfirmations.length - 1 ? '' : ',');
  126. }
  127. this.$router.push({ path: 'eam-eamProjectInfoForConfirm', query: { projectNo: projectNos,flag:'3',testPartNo: testPartNos } });
  128. }
  129. else if (path === 'overdueConfirmations') {
  130. for (let i = 0; i < row.overdueConfirmations.length; i++) {
  131. projectNos += row.overdueConfirmations[i].projectNo + (i === row.overdueConfirmations.length - 1 ? '' : ',');
  132. testPartNos += row.overdueConfirmations[i].testPartNo + (i === row.overdueConfirmations.length - 1 ? '' : ',');
  133. }
  134. this.$router.push({ path: 'eam-eamProjectInfoForConfirm', query: { projectNo: projectNos,flag:'4',testPartNo: testPartNos } });
  135. }
  136. },
  137. startAutoRefresh() {
  138. this.intervalId = setInterval(() => {
  139. this.fetchCounts();
  140. }, 20000); // 每20秒刷新一次
  141. },
  142. stopAutoRefresh() {
  143. if (this.intervalId) {
  144. clearInterval(this.intervalId);
  145. }
  146. },
  147. },
  148. };
  149. </script>
  150. <style scoped>
  151. .card-item {
  152. cursor: pointer;
  153. margin-bottom: 20px;
  154. transition: transform 0.3s, box-shadow 0.3s;
  155. overflow: hidden;
  156. //padding: 10px;
  157. display: flex;
  158. flex-direction: column;
  159. justify-content: space-between;
  160. align-items: center;
  161. height: 208px;
  162. width: 230px;
  163. margin-left: 40px;
  164. margin-top: 10px;
  165. }
  166. .card-item:hover {
  167. transform: translateY(-5px);
  168. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  169. }
  170. .card-title {
  171. font-size: 18px;
  172. font-weight: bold;
  173. margin-bottom: 10px;
  174. margin-top: 20px;
  175. }
  176. .card-count {
  177. font-size: 55px;
  178. color: #17B3A3;
  179. text-align: center;
  180. font-weight: bold;
  181. margin-top: 50px;
  182. }
  183. .project-list {
  184. font-size: 12px;
  185. color: #333;
  186. line-height: 1.5;
  187. margin-bottom: 5px;
  188. }
  189. .el-divider {
  190. margin: 10px 0;
  191. }
  192. </style>