index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <view class="report-page">
  3. <scroll-view class="report-scroll" scroll-y>
  4. <view v-if="loading" class="state-card">
  5. <text class="state-text">数据加载中...</text>
  6. </view>
  7. <view v-else-if="!dataList.length" class="state-card empty">
  8. <text class="state-text">当前日期暂无数据</text>
  9. </view>
  10. <view v-else class="report-list">
  11. <view
  12. v-for="item in sortedList"
  13. :key="item.projectDeptId"
  14. class="report-card"
  15. >
  16. <view class="card-header">
  17. <view>
  18. <view class="dept-name">{{ item.projectDeptName || "--" }}</view>
  19. </view>
  20. <view class="rate-badge" @click="openTeamDetail(item)">
  21. 查看队伍明细
  22. </view>
  23. </view>
  24. <view class="metrics-grid">
  25. <view class="metric-item">
  26. <text class="metric-label">队伍总数</text>
  27. <text class="metric-value">{{
  28. formatNumber(item.teamCount)
  29. }}</text>
  30. </view>
  31. <view class="metric-item">
  32. <text class="metric-label">施工队伍</text>
  33. <text class="metric-value">{{
  34. formatNumber(item.sgTeamCount)
  35. }}</text>
  36. </view>
  37. <view class="metric-item">
  38. <text class="metric-label">施工准备</text>
  39. <text class="metric-value">{{
  40. formatNumber(item.zbTeamCount)
  41. }}</text>
  42. </view>
  43. <view class="metric-item">
  44. <text class="metric-label">待命</text>
  45. <text class="metric-value">{{
  46. formatNumber(item.dmTeamCount)
  47. }}</text>
  48. </view>
  49. <view class="metric-item">
  50. <text class="metric-label">当日运行时效</text>
  51. <text class="metric-value">{{
  52. formatPercent(item.hourUtilizationRate)
  53. }}</text>
  54. </view>
  55. <view class="metric-item">
  56. <text class="metric-label">平均运行时效</text>
  57. <text class="metric-value">{{
  58. formatPercent(item.yearHourUtilizationRate)
  59. }}</text>
  60. </view>
  61. </view>
  62. <view class="summary-panel">
  63. <view class="summary-row">
  64. <text class="summary-label">日注水量(万方)</text>
  65. <text class="summary-value">
  66. {{ formatDecimal(item.waterInjection) }}
  67. </text>
  68. </view>
  69. <view class="summary-row">
  70. <text class="summary-label">累计注水量(万方)</text>
  71. <text class="summary-value">
  72. {{ formatDecimal(item.yearWaterInjection) }}
  73. </text>
  74. </view>
  75. <view class="summary-row">
  76. <text class="summary-label">日注气量(万方)</text>
  77. <text class="summary-value">
  78. {{ formatDecimal(item.gasInjection) }}
  79. </text>
  80. </view>
  81. <view class="summary-row">
  82. <text class="summary-label">累计注气量(万方)</text>
  83. <text class="summary-value">
  84. {{ formatDecimal(item.yearGasInjection) }}
  85. </text>
  86. </view>
  87. </view>
  88. <view class="desc-panel">
  89. <view class="desc-title">生产动态概述</view>
  90. <text class="desc-text">
  91. {{ item.productionSummary || "暂无生产动态概述" }}
  92. </text>
  93. </view>
  94. </view>
  95. </view>
  96. </scroll-view>
  97. <view class="filter-bar">
  98. <view class="filter-main">
  99. <text class="filter-label">创建时间</text>
  100. <uni-datetime-picker
  101. v-model="selectedDate"
  102. class="date-picker"
  103. type="date"
  104. :teleport="true"
  105. return-type="string"
  106. :clear-icon="false"
  107. :border="false"
  108. @change="handleDateChange"
  109. />
  110. </view>
  111. <button
  112. class="filter-button"
  113. type="primary"
  114. size="mini"
  115. @click="loadList"
  116. >
  117. 查询
  118. </button>
  119. </view>
  120. <uni-popup
  121. ref="teamDetailPopup"
  122. type="right"
  123. background-color="#fff"
  124. :is-mask-click="true"
  125. >
  126. <view class="team-drawer">
  127. <view class="team-drawer__header">
  128. <text class="team-drawer__title">
  129. {{ currentDetailTitle || "队伍明细" }}
  130. </text>
  131. <text class="team-drawer__close" @click="closeTeamDetail">关闭</text>
  132. </view>
  133. <view class="team-drawer__sub">
  134. 统计日期:{{ selectedDate || "--" }}
  135. </view>
  136. <scroll-view class="team-drawer__scroll" scroll-y>
  137. <view v-if="teamDetailLoading" class="team-state-card">
  138. <text class="team-state-text">数据加载中...</text>
  139. </view>
  140. <view
  141. v-else-if="!teamDetailList.length"
  142. class="team-state-card empty"
  143. >
  144. <text class="team-state-text">暂无队伍明细</text>
  145. </view>
  146. <view v-else class="team-detail-list">
  147. <view
  148. v-for="(team, index) in teamDetailList"
  149. :key="team.teamName || index"
  150. class="team-detail-card"
  151. >
  152. <view class="team-detail-card__title">
  153. {{ team.teamName || "--" }}
  154. </view>
  155. <view class="team-detail-grid">
  156. <view class="team-detail-item">
  157. <text class="team-detail-label">累计天数</text>
  158. <text class="team-detail-value">{{
  159. formatNumber(team.cumulativeDays)
  160. }}</text>
  161. </view>
  162. <view class="team-detail-item">
  163. <text class="team-detail-label">施工天数</text>
  164. <text class="team-detail-value">{{
  165. formatNumber(team.constructionDays)
  166. }}</text>
  167. </view>
  168. <view class="team-detail-item team-detail-item--full">
  169. <text class="team-detail-label">设备利用率</text>
  170. <text class="team-detail-value">{{
  171. formatPercent(team.utilizationRate)
  172. }}</text>
  173. </view>
  174. </view>
  175. </view>
  176. </view>
  177. </scroll-view>
  178. </view>
  179. </uni-popup>
  180. </view>
  181. </template>
  182. <script setup>
  183. import { computed, ref } from "vue";
  184. import { onMounted } from "vue";
  185. import dayjs from "dayjs";
  186. import { getRhRate, getRhTeamDetail } from "@/api/ruiHengReport";
  187. const selectedDate = ref(dayjs().subtract(1, "day").format("YYYY-MM-DD"));
  188. const dataList = ref([]);
  189. const loading = ref(false);
  190. const teamDetailPopup = ref(null);
  191. const teamDetailLoading = ref(false);
  192. const teamDetailList = ref([]);
  193. const currentDetailTitle = ref("");
  194. const buildQueryParams = () => {
  195. const baseDate = selectedDate.value
  196. ? dayjs(selectedDate.value)
  197. : dayjs().subtract(1, "day");
  198. return {
  199. createTime: [
  200. baseDate.startOf("day").format("YYYY-MM-DD HH:mm:ss"),
  201. baseDate.endOf("day").format("YYYY-MM-DD HH:mm:ss"),
  202. ],
  203. };
  204. };
  205. const sortedList = computed(() =>
  206. [...dataList.value].sort((a, b) => (a.sort ?? 999999) - (b.sort ?? 999999)),
  207. );
  208. const loadList = async () => {
  209. loading.value = true;
  210. try {
  211. const response = await getRhRate(buildQueryParams());
  212. dataList.value = Array.isArray(response?.data) ? response.data : [];
  213. } catch (error) {
  214. dataList.value = [];
  215. uni.showToast({
  216. title: "数据加载失败",
  217. icon: "none",
  218. });
  219. } finally {
  220. loading.value = false;
  221. }
  222. };
  223. const handleDateChange = () => {
  224. loadList();
  225. };
  226. const openTeamDetail = async (item) => {
  227. currentDetailTitle.value = `${item.projectDeptName || "--"} 队伍明细`;
  228. teamDetailList.value = [];
  229. teamDetailLoading.value = true;
  230. teamDetailPopup.value?.open();
  231. try {
  232. const response = await getRhTeamDetail({
  233. deptId: item.projectDeptId,
  234. createTime: buildQueryParams().createTime,
  235. });
  236. teamDetailList.value = Array.isArray(response?.data) ? response.data : [];
  237. } catch (error) {
  238. teamDetailList.value = [];
  239. uni.showToast({
  240. title: "队伍明细加载失败",
  241. icon: "none",
  242. });
  243. } finally {
  244. teamDetailLoading.value = false;
  245. }
  246. };
  247. const closeTeamDetail = () => {
  248. teamDetailPopup.value?.close();
  249. };
  250. const formatNumber = (value) => {
  251. if (value === null || value === undefined || value === "") return "--";
  252. return value;
  253. };
  254. const formatDecimal = (value) => {
  255. if (value === null || value === undefined || value === "") return "--";
  256. return Number(value).toFixed(2);
  257. };
  258. const formatPercent = (value) => {
  259. if (value === null || value === undefined || value === "") return "--";
  260. return `${(Number(value) * 100).toFixed(2)}%`;
  261. };
  262. onMounted(() => {
  263. loadList();
  264. });
  265. </script>
  266. <style lang="scss" scoped>
  267. .report-page {
  268. max-height: 100vh;
  269. padding: 12px;
  270. box-sizing: border-box;
  271. }
  272. .filter-bar {
  273. display: flex;
  274. align-items: center;
  275. gap: 10px;
  276. padding: 14px;
  277. border-radius: 18px;
  278. background: rgba(255, 255, 255, 0.94);
  279. box-shadow: 0 14px 32px rgba(25, 56, 104, 0.08);
  280. backdrop-filter: blur(10px);
  281. }
  282. .filter-main {
  283. flex: 1;
  284. min-width: 0;
  285. display: flex;
  286. align-items: center;
  287. justify-content: space-between;
  288. gap: 10rpx;
  289. }
  290. .filter-label {
  291. display: block;
  292. margin-bottom: 8px;
  293. color: #5f6f87;
  294. font-size: 12px;
  295. letter-spacing: 1px;
  296. }
  297. .date-picker {
  298. padding: 0 12px;
  299. border: 1px solid rgba(0, 64, 152, 0.1);
  300. border-radius: 12px;
  301. background: #f8fbff;
  302. }
  303. .filter-button {
  304. width: 76px;
  305. height: 38px;
  306. line-height: 40px;
  307. border-radius: 12px;
  308. background: linear-gradient(135deg, #004098 0%, #1f68d8 100%);
  309. font-size: 14px;
  310. }
  311. .filter-tip {
  312. margin: 10px 4px 0;
  313. color: #6d7c91;
  314. font-size: 12px;
  315. }
  316. .report-scroll {
  317. height: calc(100vh - 140px);
  318. padding-top: 12px;
  319. box-sizing: border-box;
  320. }
  321. .report-list {
  322. display: flex;
  323. flex-direction: column;
  324. gap: 14px;
  325. padding-bottom: 18px;
  326. }
  327. .report-card {
  328. padding: 16px;
  329. border: 1px solid rgba(0, 64, 152, 0.08);
  330. border-radius: 20px;
  331. background: rgba(255, 255, 255, 0.96);
  332. box-shadow: 0 18px 38px rgba(31, 57, 90, 0.08);
  333. }
  334. .card-header {
  335. display: flex;
  336. align-items: flex-start;
  337. justify-content: space-between;
  338. gap: 12px;
  339. margin-bottom: 14px;
  340. }
  341. .dept-name {
  342. color: #122033;
  343. font-size: 18px;
  344. font-weight: 700;
  345. line-height: 26px;
  346. }
  347. .dept-meta {
  348. margin-top: 4px;
  349. color: #7f8ca0;
  350. font-size: 12px;
  351. }
  352. .rate-badge {
  353. flex-shrink: 0;
  354. min-width: 84px;
  355. padding: 8px 12px;
  356. border-radius: 999px;
  357. background: linear-gradient(135deg, #e6f0ff 0%, #d8e7ff 100%);
  358. color: #004098;
  359. font-size: 14px;
  360. font-weight: 700;
  361. text-align: center;
  362. }
  363. .metrics-grid {
  364. display: grid;
  365. grid-template-columns: repeat(2, minmax(0, 1fr));
  366. gap: 10px;
  367. margin-bottom: 14px;
  368. }
  369. .metric-item {
  370. padding: 12px;
  371. border-radius: 14px;
  372. background: #f6f9fd;
  373. }
  374. .metric-label {
  375. display: block;
  376. color: #6e7e95;
  377. font-size: 12px;
  378. }
  379. .metric-value {
  380. display: block;
  381. margin-top: 6px;
  382. color: #18273b;
  383. font-size: 20px;
  384. font-weight: 700;
  385. }
  386. .summary-panel {
  387. display: grid;
  388. grid-template-columns: repeat(2, minmax(0, 1fr));
  389. gap: 8px 14px;
  390. padding: 14px 0;
  391. border-top: 1px solid #edf2f7;
  392. border-bottom: 1px solid #edf2f7;
  393. }
  394. .summary-row {
  395. display: flex;
  396. align-items: center;
  397. justify-content: space-between;
  398. gap: 10px;
  399. }
  400. .summary-label {
  401. color: #6d7c91;
  402. font-size: 12px;
  403. }
  404. .summary-value {
  405. color: #17253a;
  406. font-size: 13px;
  407. font-weight: 600;
  408. }
  409. .desc-panel {
  410. padding-top: 14px;
  411. }
  412. .desc-title {
  413. margin-bottom: 8px;
  414. color: #1f2f46;
  415. font-size: 14px;
  416. font-weight: 700;
  417. }
  418. .desc-text {
  419. color: #5f6f87;
  420. font-size: 13px;
  421. line-height: 22px;
  422. white-space: pre-wrap;
  423. }
  424. .state-card {
  425. margin-top: 18px;
  426. padding: 40px 20px;
  427. border-radius: 18px;
  428. background: rgba(255, 255, 255, 0.92);
  429. text-align: center;
  430. box-shadow: 0 12px 28px rgba(30, 54, 88, 0.06);
  431. }
  432. .state-card.empty {
  433. border: 1px dashed rgba(0, 64, 152, 0.16);
  434. }
  435. .state-text {
  436. color: #73839a;
  437. font-size: 14px;
  438. }
  439. .team-drawer {
  440. width: 82vw;
  441. max-width: 620rpx;
  442. height: 100vh;
  443. padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  444. box-sizing: border-box;
  445. background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  446. display: flex;
  447. flex-direction: column;
  448. }
  449. .team-drawer__header {
  450. display: flex;
  451. align-items: center;
  452. justify-content: space-between;
  453. gap: 12px;
  454. }
  455. .team-drawer__title {
  456. min-width: 0;
  457. color: #122033;
  458. font-size: 18px;
  459. font-weight: 700;
  460. }
  461. .team-drawer__close {
  462. flex-shrink: 0;
  463. color: #004098;
  464. font-size: 14px;
  465. font-weight: 600;
  466. }
  467. .team-drawer__sub {
  468. margin-top: 8px;
  469. margin-bottom: 14px;
  470. color: #70819a;
  471. font-size: 12px;
  472. }
  473. .team-drawer__scroll {
  474. flex: 1;
  475. min-height: 0;
  476. padding-bottom: 50rpx;
  477. }
  478. .team-detail-list {
  479. display: flex;
  480. flex-direction: column;
  481. gap: 12px;
  482. padding-bottom: 10px;
  483. }
  484. .team-detail-card {
  485. padding: 14px;
  486. border-radius: 16px;
  487. background: rgba(255, 255, 255, 0.96);
  488. box-shadow: 0 10px 24px rgba(31, 57, 90, 0.08);
  489. }
  490. .team-detail-card__title {
  491. margin-bottom: 12px;
  492. color: #18273b;
  493. font-size: 16px;
  494. font-weight: 700;
  495. }
  496. .team-detail-grid {
  497. display: grid;
  498. grid-template-columns: repeat(2, minmax(0, 1fr));
  499. gap: 10px;
  500. }
  501. .team-detail-item {
  502. padding: 10px 12px;
  503. border-radius: 12px;
  504. background: #f6f9fd;
  505. }
  506. .team-detail-item--full {
  507. grid-column: 1 / -1;
  508. }
  509. .team-detail-label {
  510. display: block;
  511. color: #6e7e95;
  512. font-size: 12px;
  513. }
  514. .team-detail-value {
  515. display: block;
  516. margin-top: 6px;
  517. color: #18273b;
  518. font-size: 18px;
  519. font-weight: 700;
  520. }
  521. .team-state-card {
  522. margin-top: 8px;
  523. padding: 36px 20px;
  524. border-radius: 16px;
  525. background: rgba(255, 255, 255, 0.92);
  526. text-align: center;
  527. box-shadow: 0 12px 28px rgba(30, 54, 88, 0.06);
  528. }
  529. .team-state-card.empty {
  530. border: 1px dashed rgba(0, 64, 152, 0.16);
  531. }
  532. .team-state-text {
  533. color: #73839a;
  534. font-size: 14px;
  535. }
  536. </style>