index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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, index) in dataList"
  13. :key="index"
  14. class="report-card"
  15. >
  16. <!-- 基本信息 -->
  17. <view class="card-header">
  18. <view class="header-left">
  19. <text class="company-name">{{
  20. item.projectClassification || "--"
  21. }}</text>
  22. <text class="project-name">{{ item.projectName || "--" }}</text>
  23. </view>
  24. <view
  25. class="status-badge"
  26. :class="getStatusClass(item.constructionStatusName)"
  27. >
  28. {{ item.constructionStatusName || "--" }}
  29. </view>
  30. </view>
  31. <!-- 队伍和任务 -->
  32. <view class="info-row">
  33. <view class="info-item">
  34. <text class="info-label">队伍</text>
  35. <text class="info-value">{{ item.deptName || "--" }}</text>
  36. </view>
  37. <view class="info-item">
  38. <text class="info-label">生产任务</text>
  39. <text class="info-value">{{ item.taskName || "--" }}</text>
  40. </view>
  41. </view>
  42. <!-- 核心指标 -->
  43. <view class="metrics-grid">
  44. <view class="metric-item">
  45. <text class="metric-label">当日进尺/井次</text>
  46. <text class="metric-value">{{ formatFootageOrWell(item) }}</text>
  47. </view>
  48. <view class="metric-item">
  49. <text class="metric-label">当日电耗</text>
  50. <text class="metric-value"
  51. >{{ formatNumber(item.dailyPowerUsage) }}kWh</text
  52. >
  53. </view>
  54. <view class="metric-item">
  55. <text class="metric-label">当日油耗</text>
  56. <text class="metric-value"
  57. >{{ formatNumber(item.dailyFuel) }}L</text
  58. >
  59. </view>
  60. <view class="metric-item">
  61. <text class="metric-label">非生产时间</text>
  62. <text class="metric-value"
  63. >{{ formatNumber(item.nonProductionTime) }}h</text
  64. >
  65. </view>
  66. </view>
  67. <!-- 下步任务 -->
  68. <view class="desc-panel" v-if="item.nextPlan">
  69. <view class="desc-title">下步任务</view>
  70. <text class="desc-text">{{ item.nextPlan }}</text>
  71. </view>
  72. <!-- 当日生产简况 -->
  73. <view class="desc-panel" v-if="item.constructionBrief">
  74. <view class="desc-title">当日生产简况</view>
  75. <text class="desc-text">{{ item.constructionBrief }}</text>
  76. </view>
  77. </view>
  78. </view>
  79. </scroll-view>
  80. <!-- 筛选栏 -->
  81. <view class="filter-bar">
  82. <view class="filter-main">
  83. <text class="filter-label">日期</text>
  84. <uni-datetime-picker
  85. v-model="selectedDate"
  86. class="date-picker"
  87. type="date"
  88. :teleport="true"
  89. return-type="string"
  90. :clear-icon="false"
  91. :border="false"
  92. @change="handleDateChange"
  93. />
  94. </view>
  95. <button
  96. class="filter-button"
  97. type="primary"
  98. size="mini"
  99. @click="loadList"
  100. >
  101. 查询
  102. </button>
  103. </view>
  104. </view>
  105. </template>
  106. <script setup>
  107. import { ref, onMounted } from "vue";
  108. import dayjs from "dayjs";
  109. // 假设接口地址为 getRyProductionBriefs,请根据实际接口调整
  110. import { getRyProductionBriefs } from "@/api/ruiYingReport";
  111. // 状态
  112. const selectedDate = ref(dayjs().subtract(1, "day").format("YYYY-MM-DD"));
  113. const dataList = ref([]);
  114. const loading = ref(false);
  115. // 构建查询参数
  116. const buildQueryParams = () => {
  117. const baseDate = selectedDate.value
  118. ? dayjs(selectedDate.value)
  119. : dayjs().subtract(1, "day");
  120. return {
  121. createTime: [
  122. baseDate.startOf("day").format("YYYY-MM-DD HH:mm:ss"),
  123. baseDate.endOf("day").format("YYYY-MM-DD HH:mm:ss"),
  124. ],
  125. };
  126. };
  127. // 格式化数字
  128. const formatNumber = (value, fractionDigits = 1) => {
  129. if (value === null || value === undefined || value === "") return "--";
  130. const numberValue = Number(value);
  131. if (isNaN(numberValue)) return "--";
  132. if (Number.isInteger(numberValue)) {
  133. return `${numberValue}`;
  134. }
  135. return numberValue.toFixed(fractionDigits);
  136. };
  137. // 格式化进尺/井次
  138. const formatFootageOrWell = (row) => {
  139. if (!row) return "--";
  140. if (row.projectClassification === "钻井") {
  141. const footage = formatNumber(row.dailyFootage);
  142. return footage === "--" ? "--" : `${footage}m`;
  143. }
  144. return formatNumber(row.completedWells, 0);
  145. };
  146. // 获取状态样式
  147. const getStatusClass = (status) => {
  148. if (!status) return "";
  149. const statusMap = {
  150. 施工中: "status-construction",
  151. 待命: "status-standby",
  152. 停工: "status-stopped",
  153. 完工: "status-completed",
  154. 准备: "status-ready",
  155. };
  156. return statusMap[status] || "";
  157. };
  158. // 加载数据
  159. const loadList = async () => {
  160. loading.value = true;
  161. try {
  162. const response = await getRyProductionBriefs(buildQueryParams());
  163. dataList.value = Array.isArray(response?.data) ? response.data : [];
  164. } catch (error) {
  165. dataList.value = [];
  166. uni.showToast({
  167. title: "数据加载失败",
  168. icon: "none",
  169. });
  170. } finally {
  171. loading.value = false;
  172. }
  173. };
  174. // 日期变化处理
  175. const handleDateChange = () => {
  176. loadList();
  177. };
  178. // 生命周期
  179. onMounted(() => {
  180. loadList();
  181. });
  182. </script>
  183. <style lang="scss" scoped>
  184. .report-page {
  185. max-height: 100vh;
  186. padding: 12px;
  187. box-sizing: border-box;
  188. }
  189. // 筛选栏
  190. .filter-bar {
  191. display: flex;
  192. align-items: center;
  193. gap: 10px;
  194. padding: 14px;
  195. border-radius: 18px;
  196. background: rgba(255, 255, 255, 0.94);
  197. box-shadow: 0 14px 32px rgba(25, 56, 104, 0.08);
  198. backdrop-filter: blur(10px);
  199. }
  200. .filter-main {
  201. flex: 1;
  202. min-width: 0;
  203. display: flex;
  204. align-items: center;
  205. justify-content: space-between;
  206. gap: 10rpx;
  207. }
  208. .filter-label {
  209. display: block;
  210. margin-bottom: 8px;
  211. color: #5f6f87;
  212. font-size: 12px;
  213. letter-spacing: 1px;
  214. }
  215. .date-picker {
  216. padding: 0 12px;
  217. border: 1px solid rgba(0, 64, 152, 0.1);
  218. border-radius: 12px;
  219. background: #f8fbff;
  220. }
  221. .filter-button {
  222. width: 76px;
  223. height: 38px;
  224. line-height: 40px;
  225. border-radius: 12px;
  226. background: linear-gradient(135deg, #004098 0%, #1f68d8 100%);
  227. font-size: 14px;
  228. }
  229. // 滚动区域
  230. .report-scroll {
  231. height: calc(100vh - 140px);
  232. padding-top: 12px;
  233. box-sizing: border-box;
  234. }
  235. // 列表
  236. .report-list {
  237. display: flex;
  238. flex-direction: column;
  239. gap: 14px;
  240. padding-bottom: 18px;
  241. }
  242. // 卡片
  243. .report-card {
  244. padding: 16px;
  245. border: 1px solid rgba(0, 64, 152, 0.08);
  246. border-radius: 20px;
  247. background: rgba(255, 255, 255, 0.96);
  248. box-shadow: 0 18px 38px rgba(31, 57, 90, 0.08);
  249. }
  250. // 头部
  251. .card-header {
  252. display: flex;
  253. align-items: flex-start;
  254. justify-content: space-between;
  255. gap: 12px;
  256. margin-bottom: 12px;
  257. }
  258. .header-left {
  259. display: flex;
  260. flex-direction: column;
  261. gap: 4px;
  262. flex: 1;
  263. min-width: 0;
  264. }
  265. .company-name {
  266. color: #122033;
  267. font-size: 18px;
  268. font-weight: 700;
  269. line-height: 26px;
  270. }
  271. .project-name {
  272. color: #5f6f87;
  273. font-size: 14px;
  274. line-height: 20px;
  275. }
  276. // 状态标签
  277. .status-badge {
  278. flex-shrink: 0;
  279. padding: 4px 14px;
  280. border-radius: 999px;
  281. font-size: 13px;
  282. font-weight: 600;
  283. text-align: center;
  284. background: linear-gradient(135deg, #e6f0ff 0%, #d8e7ff 100%);
  285. color: #004098;
  286. }
  287. .status-construction {
  288. background: #e6f7e6;
  289. color: #52c41a;
  290. }
  291. .status-standby {
  292. background: #fff7e6;
  293. color: #faad14;
  294. }
  295. .status-stopped {
  296. background: #fde6e6;
  297. color: #ff4d4f;
  298. }
  299. .status-completed {
  300. background: #e6f0ff;
  301. color: #1890ff;
  302. }
  303. .status-ready {
  304. background: #f0f0f0;
  305. color: #8c8c8c;
  306. }
  307. // 信息行
  308. .info-row {
  309. display: grid;
  310. grid-template-columns: 1fr 1fr;
  311. gap: 8px 16px;
  312. padding: 12px 0;
  313. border-top: 1px solid #f0f2f5;
  314. border-bottom: 1px solid #f0f2f5;
  315. }
  316. .info-item {
  317. display: flex;
  318. flex-direction: column;
  319. gap: 4px;
  320. }
  321. .info-label {
  322. color: #6d7c91;
  323. font-size: 12px;
  324. }
  325. .info-value {
  326. color: #17253a;
  327. font-size: 14px;
  328. font-weight: 600;
  329. }
  330. // 指标网格
  331. .metrics-grid {
  332. display: grid;
  333. grid-template-columns: repeat(2, 1fr);
  334. gap: 10px;
  335. padding: 12px 0;
  336. border-bottom: 1px solid #f0f2f5;
  337. }
  338. .metric-item {
  339. padding: 12px;
  340. border-radius: 14px;
  341. background: #f6f9fd;
  342. }
  343. .metric-label {
  344. display: block;
  345. color: #6e7e95;
  346. font-size: 12px;
  347. }
  348. .metric-value {
  349. display: block;
  350. margin-top: 6px;
  351. color: #18273b;
  352. font-size: 18px;
  353. font-weight: 700;
  354. }
  355. // 描述面板
  356. .desc-panel {
  357. padding-top: 14px;
  358. }
  359. .desc-panel + .desc-panel {
  360. border-top: 1px solid #f0f2f5;
  361. padding-top: 14px;
  362. margin-top: 0;
  363. }
  364. .desc-title {
  365. margin-bottom: 6px;
  366. color: #1f2f46;
  367. font-size: 14px;
  368. font-weight: 700;
  369. }
  370. .desc-text {
  371. color: #5f6f87;
  372. font-size: 13px;
  373. line-height: 22px;
  374. white-space: pre-wrap;
  375. }
  376. // 空状态
  377. .state-card {
  378. margin-top: 18px;
  379. padding: 40px 20px;
  380. border-radius: 18px;
  381. background: rgba(255, 255, 255, 0.92);
  382. text-align: center;
  383. box-shadow: 0 12px 28px rgba(30, 54, 88, 0.06);
  384. }
  385. .state-card.empty {
  386. border: 1px dashed rgba(0, 64, 152, 0.16);
  387. }
  388. .state-text {
  389. color: #73839a;
  390. font-size: 14px;
  391. }
  392. </style>