rdkb.vue 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009
  1. <template>
  2. <div class="min-h-screen p-4 bg-[#3a6fa3] flex flex-col">
  3. <el-row :gutter="16" class="summary">
  4. <!-- 原有的统计卡片部分保持不变 -->
  5. <el-col v-loading="loading" :sm="3" :xs="24">
  6. <SummaryCard
  7. :value="device.total || 0"
  8. icon="fa-solid:project-diagram"
  9. icon-bg-color="text-blue-500"
  10. icon-color="bg-blue-100"
  11. :title="t('stat.deviceCount')"
  12. />
  13. </el-col>
  14. <el-col v-loading="loading" :sm="3" :xs="24">
  15. <SummaryCard
  16. :value="maintain.total || 0"
  17. icon="fa-solid:list"
  18. icon-bg-color="text-pink-500"
  19. icon-color="bg-blue-100"
  20. :title="t('stat.repairOrder')"
  21. />
  22. </el-col>
  23. <el-col v-loading="loading" :sm="3" :xs="24">
  24. <SummaryCard
  25. :value="fill.unfilledCount || 0"
  26. icon="fa-solid:times-circle"
  27. icon-bg-color="text-purple-500"
  28. icon-color="bg-purple-100"
  29. :title="t('stat.operationNotFilled')"
  30. />
  31. </el-col>
  32. <el-col v-loading="loading" :sm="3" :xs="24">
  33. <SummaryCard
  34. :value="fill.filledCount || 0"
  35. icon="fa-solid:award"
  36. icon-bg-color="text-purple-500"
  37. icon-color="bg-purple-100"
  38. :title="t('stat.operationFilled')"
  39. />
  40. </el-col>
  41. <el-col v-loading="loading" :sm="3" :xs="24">
  42. <SummaryCard
  43. :value="by.todo || 0"
  44. icon="fa-solid:times-circle"
  45. icon-bg-color="text-green-500"
  46. icon-color="bg-green-100"
  47. :title="t('stat.notMaintained')"
  48. />
  49. </el-col>
  50. <el-col v-loading="loading" :sm="3" :xs="24">
  51. <SummaryCard
  52. :value="by.finished || 0"
  53. icon="fa-solid:award"
  54. icon-bg-color="text-green-500"
  55. icon-color="bg-green-100"
  56. :title="t('stat.maintained')"
  57. />
  58. </el-col>
  59. <el-col v-loading="loading" :sm="3" :xs="24">
  60. <SummaryCard
  61. :value="inspect.todo || 0"
  62. icon="fa-solid:times-circle"
  63. icon-bg-color="text-yellow-500"
  64. icon-color="bg-yellow-100"
  65. :title="t('stat.notInspected')"
  66. />
  67. </el-col>
  68. <el-col v-loading="loading" :sm="3" :xs="12">
  69. <SummaryCard
  70. :value="inspect.finished || 0"
  71. icon="fa-solid:award"
  72. icon-bg-color="text-yellow-500"
  73. icon-color="bg-yellow-100"
  74. :title="t('stat.inspected')"
  75. />
  76. </el-col>
  77. </el-row>
  78. <el-row :gutter="16" class="mb-4">
  79. <!-- 设备状态统计和工单数量情况图表部分保持不变 -->
  80. <el-col :span="6" :xs="24">
  81. <el-card class="chart-card" shadow="never">
  82. <template #header>
  83. <div class="flex items-center">
  84. <span class="text-base font-medium" style="color: #b6c8da">{{
  85. t('stat.deviceStatus')
  86. }}</span>
  87. </div>
  88. </template>
  89. <div
  90. style="
  91. display: flex;
  92. align-items: center;
  93. justify-content: center;
  94. min-height: 290px;
  95. flex-direction: column;
  96. gap: 6px;
  97. "
  98. >
  99. <div ref="statusChartRef" style="width: 100%; height: 170px; max-width: 200px"></div>
  100. <div class="text-[12px] h-[100px] w-[90%] flex flex-col justify-between items-center">
  101. <div v-for="item in legendData" :key="item.name" class="flex">
  102. <div class="flex items-center gap-1">
  103. <span class="status-legend-color" :style="{ background: item.color }"></span>
  104. <span class="w-[100px] text-[#fff]">{{ item.name }}</span>
  105. </div>
  106. <div class="flex items-center">
  107. <span class="text-[#fff] text-right w-12">{{ item.value }} 台</span>
  108. <span class="status-legend-percent text-right w-14">{{ item.percent }}%</span>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </el-card>
  114. </el-col>
  115. <el-col :span="10" :xs="24">
  116. <el-card class="chart-card" shadow="never">
  117. <template #header>
  118. <div class="flex items-center justify-between">
  119. <span class="text-base font-medium" style="color: #b6c8da"
  120. >设备分布及价值(国内RMB)</span
  121. >
  122. </div>
  123. </template>
  124. <div
  125. style="
  126. display: flex;
  127. min-height: 295px;
  128. flex-direction: column;
  129. align-items: center;
  130. gap: 8px;
  131. "
  132. >
  133. <div ref="domesticChartRef" style="width: 100%; height: 200px; max-width: 420px"></div>
  134. <div
  135. class="domestic-legend"
  136. style="
  137. display: flex;
  138. width: 100%;
  139. max-width: 520px;
  140. font-size: 12px;
  141. flex-wrap: wrap;
  142. gap: 1px;
  143. "
  144. >
  145. <div
  146. v-for="(item, idx) in domesticData"
  147. :key="item.dept"
  148. class="legend-item"
  149. style="display: flex; align-items: center; gap: 8px; padding: 4px 8px"
  150. >
  151. <span
  152. class="legend-dot"
  153. :style="{
  154. background: statusColors[idx % statusColors.length],
  155. width: '10px',
  156. height: '10px',
  157. display: 'inline-block',
  158. borderRadius: '50%'
  159. }"
  160. ></span>
  161. <span
  162. class="legend-name"
  163. style="
  164. display: inline-block;
  165. max-width: 150px;
  166. overflow: hidden;
  167. color: #fff;
  168. text-overflow: ellipsis;
  169. white-space: nowrap;
  170. "
  171. >{{ item.dept }}</span
  172. >
  173. </div>
  174. </div>
  175. </div>
  176. </el-card>
  177. </el-col>
  178. <el-col :span="8" :xs="24">
  179. <WorkloadChart />
  180. <!-- <el-card class="chart-card" shadow="never">
  181. <template #header>
  182. <div class="flex items-center justify-between">
  183. <span class="text-base font-medium" style="color: #b6c8da">{{
  184. t('stat.orderCount')
  185. }}</span>
  186. </div>
  187. </template>
  188. <div ref="qxRef" class="h-[290px]"></div>
  189. </el-card> -->
  190. </el-col>
  191. </el-row>
  192. <el-row :gutter="16" class="mb-4">
  193. <el-col class="mb-4" :span="12" :xs="24">
  194. <AvailabilityChart />
  195. </el-col>
  196. <el-col class="mb-4" :span="12" :xs="24">
  197. <ExceptionChart />
  198. </el-col>
  199. </el-row>
  200. <el-row :gutter="16" class="mb-4">
  201. <el-col :span="12" :xs="24">
  202. <UtilizationChart />
  203. </el-col>
  204. <!-- <el-card class="chart-card" shadow="never">
  205. <template #header>
  206. <div style="display: flex; flex-direction: row; justify-content: space-between">
  207. <span class="text-base font-medium" style="color: #b6c8da">{{
  208. t('stat.deviceRate')
  209. }}</span>
  210. <div>
  211. <el-date-picker
  212. v-model="rateQueryParams.createTime"
  213. value-format="YYYY-MM-DD HH:mm:ss"
  214. type="daterange"
  215. start-placeholder="开始日期"
  216. end-placeholder="结束日期"
  217. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  218. class="!w-220px"
  219. @change="handleDateChange"
  220. />
  221. </div>
  222. </div>
  223. </template>
  224. <div class="table-container">
  225. <div ref="utilizationRef" style="width: 100%; height: 360px"></div>
  226. </div>
  227. </el-card> -->
  228. <!-- 添加两个卡片 -->
  229. <!-- <div class="flex justify-between mb-2">-->
  230. <!-- <el-card class="stat-card">-->
  231. <!-- <div class="flex flex-row justify-evenly">-->
  232. <!-- <div>-->
  233. <!-- <Icon icon="fa-solid:award" size="30" color="blue" />-->
  234. <!-- </div>-->
  235. <!-- <div class="flex flex-col items-center">-->
  236. <!-- <span class="text-sm " style="color: #101010">{{t('stat.spareCount')}}</span>-->
  237. <!-- <span class="text-lg font-bold">{{ totalMaterialCount }}</span>-->
  238. <!-- </div>-->
  239. <!-- </div>-->
  240. <!-- </el-card>-->
  241. <!-- <el-card class="stat-card">-->
  242. <!-- <div class="flex flex-row justify-evenly">-->
  243. <!-- <div>-->
  244. <!-- <Icon icon="fa-solid:yen-sign" size="30" color="orange" />-->
  245. <!-- </div>-->
  246. <!-- <div class="flex flex-col items-center">-->
  247. <!-- <span class="text-sm " style="color: #101010">{{t('stat.spareAmount')}}</span>-->
  248. <!-- <span class="text-lg font-bold">{{ totalMaterialCost }}</span>-->
  249. <!-- </div>-->
  250. <!-- </div>-->
  251. <!-- </el-card>-->
  252. <!-- </div>-->
  253. <!-- <div ref="sparePartRef" class="h-[330px]"></div>-->
  254. <!-- 月度工作量表 -->
  255. <el-col :span="12" :xs="24">
  256. <el-card class="chart-card" shadow="never">
  257. <template #header>
  258. <div class="flex items-center justify-between">
  259. <span class="text-base font-medium" style="color: #b6c8da">月度工作量表</span>
  260. </div>
  261. </template>
  262. <div class="overflow-auto">
  263. <el-table
  264. :data="monthData"
  265. border
  266. height="420px"
  267. :disabled-affix="true"
  268. style="width: 100%"
  269. :header-cell-style="{ color: '#fff', 'background-color': 'transparent' }"
  270. :cell-style="{ color: '#fff' }"
  271. :summary-method="tableSummary"
  272. show-summary
  273. >
  274. <el-table-column prop="month" label="月份" width="50" fixed="left" align="center" />
  275. <el-table-column label="2025年" align="center">
  276. <el-table-column
  277. prop="y2025_fractures"
  278. label="压裂井数"
  279. align="center"
  280. min-width="50"
  281. />
  282. <el-table-column
  283. prop="y2025_layers"
  284. label="压裂层数"
  285. min-width="50"
  286. align="center"
  287. />
  288. <el-table-column
  289. prop="y2025_pump_trips"
  290. label="泵车台次"
  291. min-width="50"
  292. align="center"
  293. />
  294. <el-table-column
  295. prop="y2025_oil_wells"
  296. label="连油井数"
  297. min-width="50"
  298. align="center"
  299. />
  300. </el-table-column>
  301. <el-table-column label="2024年" align="center">
  302. <el-table-column
  303. prop="y2024_fractures"
  304. label="压裂井数"
  305. min-width="50"
  306. align="center"
  307. />
  308. <el-table-column
  309. prop="y2024_layers"
  310. label="压裂层数"
  311. min-width="50"
  312. align="center"
  313. />
  314. <el-table-column
  315. prop="y2024_pump_trips"
  316. label="泵车台次"
  317. min-width="50"
  318. align="center"
  319. />
  320. <el-table-column
  321. prop="y2024_oil_wells"
  322. label="连油井数"
  323. min-width="50"
  324. align="center"
  325. />
  326. </el-table-column>
  327. <el-table-column label="同比增长量" align="center">
  328. <el-table-column
  329. prop="diff_fractures"
  330. label="压裂井数"
  331. min-width="50"
  332. align="center"
  333. />
  334. <el-table-column
  335. prop="diff_layers"
  336. label="压裂层数"
  337. min-width="50"
  338. align="center"
  339. />
  340. <el-table-column
  341. prop="diff_pump_trips"
  342. label="泵车台次"
  343. min-width="50"
  344. align="center"
  345. />
  346. <el-table-column
  347. prop="diff_oil_wells"
  348. label="连油井数"
  349. min-width="50"
  350. align="center"
  351. />
  352. </el-table-column>
  353. </el-table>
  354. </div>
  355. </el-card>
  356. </el-col>
  357. <!-- 月度工作量表结束 -->
  358. </el-row>
  359. <ConstructionBriefing />
  360. <!-- <el-row :gutter="16" class="mb-4">
  361. <el-col :span="24" :xs="24">
  362. </el-col>
  363. </el-row> -->
  364. </div>
  365. <el-dialog
  366. v-model="teamDialogVisible"
  367. :title="t('stat.teamDetail')"
  368. width="80vh"
  369. :before-close="handleDialogClose"
  370. class="custom-scroll-dialog"
  371. >
  372. <div class="dialog-scroll-content">
  373. <el-table
  374. :data="teamTableData"
  375. border
  376. style="width: 100%"
  377. :header-cell-style="{ 'background-color': 'transparent' }"
  378. >
  379. <el-table-column prop="teamName" label="队伍名称" align="center" />
  380. <el-table-column prop="cumulativeDays" label="累计天数" align="center" />
  381. <el-table-column prop="constructionDays" label="施工天数" align="center" />
  382. <el-table-column
  383. prop="utilizationRate"
  384. label="设备利用率"
  385. align="center"
  386. :formatter="formatRate"
  387. />
  388. </el-table>
  389. </div>
  390. </el-dialog>
  391. <el-dialog v-model="projectDataDialog" width="45vw" class="custom-scroll-dialog">
  392. <div class="dialog-scroll-content">
  393. <el-card class="bg-[#284d72]!" shadow="never">
  394. <template #header>
  395. <div class="flex items-center justify-between">
  396. <span class="text-base font-medium" style="color: #b6c8da"
  397. >国内设备分布及价值(国内RMB)</span
  398. >
  399. </div>
  400. </template>
  401. <div class="overflow-auto" style="min-height: 260px">
  402. <el-table
  403. :data="domesticData"
  404. border
  405. :header-cell-style="{ color: '#fff', 'background-color': 'transparent' }"
  406. :cell-style="{ color: '#fff' }"
  407. style="width: 100%"
  408. :summary-method="tableSummary"
  409. show-summary
  410. >
  411. <el-table-column prop="index" label="序号" width="60" align="center" fixed="left" />
  412. <el-table-column prop="dept" label="项目部" width="120" align="center" fixed="left" />
  413. <el-table-column prop="count" label="设备数量" min-width="100" align="center" />
  414. <el-table-column
  415. prop="orig_value"
  416. label="原值(万元)"
  417. min-width="120"
  418. align="center"
  419. />
  420. <el-table-column prop="net_value" label="净值(万元)" min-width="120" align="center" />
  421. <el-table-column prop="orig_ratio" label="原值占比" min-width="100" align="center" />
  422. </el-table>
  423. </div>
  424. </el-card>
  425. </div>
  426. </el-dialog>
  427. <el-dialog v-model="projectDataDialog2" width="45vw" class="custom-scroll-dialog">
  428. <div class="dialog-scroll-content">
  429. <el-card class="bg-[#284d72]!" shadow="never">
  430. <template #header>
  431. <div class="flex items-center justify-between">
  432. <span class="text-base font-medium" style="color: #b6c8da"
  433. >伊拉克设备分布及价值(美元)</span
  434. >
  435. </div>
  436. </template>
  437. <div class="overflow-auto" style="min-height: 260px">
  438. <el-table
  439. :data="iraqTableData"
  440. border
  441. :header-cell-style="{ color: '#fff', 'background-color': 'transparent' }"
  442. :cell-style="{ color: '#fff' }"
  443. style="width: 100%"
  444. >
  445. <el-table-column prop="index" label="序号" width="60" align="center" fixed="left" />
  446. <el-table-column prop="dept" label="项目部" width="120" align="center" fixed="left" />
  447. <el-table-column prop="count" label="设备数量" min-width="100" align="center" />
  448. <el-table-column
  449. prop="orig_value_usd"
  450. label="原值(万元)"
  451. min-width="120"
  452. align="center"
  453. />
  454. <el-table-column
  455. prop="net_value_usd"
  456. label="净值(万元)"
  457. min-width="120"
  458. align="center"
  459. />
  460. <el-table-column prop="orig_ratio" label="原值占比" min-width="100" align="center" />
  461. </el-table>
  462. </div>
  463. </el-card>
  464. </div>
  465. </el-dialog>
  466. <el-dialog v-model="projectDataDialog3" width="45vw" class="custom-scroll-dialog">
  467. <div class="dialog-scroll-content">
  468. <el-card class="bg-[#284d72]!" shadow="never">
  469. <template #header>
  470. <div class="flex items-center justify-between">
  471. <span class="text-base font-medium" style="color: #b6c8da"
  472. >利比亚设备分布及价值(第纳尔)</span
  473. >
  474. </div>
  475. </template>
  476. <div class="overflow-auto" style="min-height: 260px">
  477. <el-table
  478. :data="libyaTableData"
  479. border
  480. :header-cell-style="{ color: '#fff', 'background-color': 'transparent' }"
  481. :cell-style="{ color: '#fff' }"
  482. :row-class-name="tableRowClass"
  483. style="width: 100%"
  484. :summary-method="tableSummary"
  485. >
  486. <el-table-column prop="index" label="序号" width="60" align="center" fixed="left" />
  487. <el-table-column prop="dept" label="项目部" width="120" align="center" fixed="left" />
  488. <el-table-column prop="count" label="设备数量" min-width="100" align="center" />
  489. <el-table-column
  490. prop="orig_value"
  491. label="原值(万元)"
  492. min-width="120"
  493. align="center"
  494. />
  495. <el-table-column prop="net_value" label="净值(万元)" min-width="120" align="center" />
  496. <el-table-column prop="orig_ratio" label="原值占比" min-width="100" align="center" />
  497. </el-table>
  498. </div>
  499. </el-card>
  500. </div>
  501. </el-dialog>
  502. </template>
  503. <script lang="ts" setup>
  504. import { MemberSummaryRespVO } from '@/api/mall/statistics/member'
  505. import SummaryCard from '@/components/SummaryCard/index.vue'
  506. import * as echarts from 'echarts/core'
  507. import { BarChart, GaugeChart, LineChart, PieChart } from 'echarts/charts' // 显式导入柱状图模块
  508. import {
  509. GridComponent,
  510. LegendComponent,
  511. TitleComponent,
  512. ToolboxComponent,
  513. TooltipComponent
  514. } from 'echarts/components'
  515. import { LabelLayout, UniversalTransition } from 'echarts/features'
  516. import { CanvasRenderer } from 'echarts/renderers'
  517. import { IotStatApi } from '@/api/pms/stat'
  518. import { ref, onMounted, computed, watch, nextTick, reactive } from 'vue'
  519. import { useLocaleStore } from '@/store/modules/locale'
  520. import WorkloadChart from './rdkb/workload.vue'
  521. import UtilizationChart from './rdkb/utilization.vue'
  522. import AvailabilityChart from './rdkb/availability.vue'
  523. import ExceptionChart from './rdkb/exception.vue'
  524. import ConstructionBriefing from './rdkb/constructionBriefing.vue'
  525. /** 会员统计 */
  526. defineOptions({ name: 'IotRdStat' })
  527. echarts.use([
  528. TooltipComponent,
  529. LegendComponent,
  530. PieChart,
  531. CanvasRenderer,
  532. LabelLayout,
  533. TitleComponent,
  534. ToolboxComponent,
  535. GridComponent,
  536. LineChart,
  537. UniversalTransition,
  538. GaugeChart,
  539. BarChart
  540. ])
  541. const loading = ref(true) // 加载中
  542. const teamDialogVisible = ref(false)
  543. const teamTableData = ref([])
  544. const currentDeptId = ref('')
  545. const currentDateRange = ref([])
  546. const materialTableData = ref([])
  547. const handleDateChange = () => {
  548. IotStatApi.getRdRate(rateQueryParams).then((res) => {
  549. materialTableData.value = res
  550. })
  551. }
  552. const rateQueryParams = reactive({
  553. createTime: []
  554. })
  555. const handleDialogClose = () => {
  556. teamDialogVisible.value = false
  557. teamTableData.value = [] // 清空表格数据
  558. }
  559. // 格式化利用率为百分比
  560. const formatRate = (row) => {
  561. return (row.utilizationRate * 100).toFixed(2) + '%'
  562. }
  563. // 数字格式化为千分位,保留两位小数
  564. const formatNumber = (v) => {
  565. if (v == null || v === '') return '-'
  566. const n = Number(v)
  567. if (isNaN(n)) return String(v)
  568. return n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
  569. }
  570. const handleRowClick = (row, column, event) => {
  571. console.log('点击的行数据:', row)
  572. currentDeptId.value = row.deptId // 假设行数据中包含deptId字段
  573. currentDateRange.value = rateQueryParams.createTime
  574. // 打开弹窗并加载队伍详情数据
  575. teamDialogVisible.value = true
  576. // fetchTeamDetailData(row.deptId, rateQueryParams.createTime)
  577. // debugger
  578. const teamParams = {
  579. deptId: row.projectDeptId,
  580. createTime: rateQueryParams.createTime
  581. }
  582. IotStatApi.getRdTeamRate(teamParams).then((res) => {
  583. teamTableData.value = res
  584. })
  585. }
  586. const dateRange = ref<[Date, Date] | null>(null)
  587. const summary = ref<MemberSummaryRespVO>() // 会员统计数据
  588. const statusChartRef = ref() // 设备数量统计的图表
  589. let statusChartInstance = null
  590. const qxRef = ref(null)
  591. let qxInstance = null
  592. const sparePartRef = ref(null)
  593. let sparePartInstance = null
  594. const maintenanceChartRef = ref(null)
  595. let maintenanceChartInstance = null
  596. const inspectChartRef = ref(null)
  597. let inspectChartInstance = null
  598. const inspectionChartRef = ref(null)
  599. let inspectionChartInstance = null
  600. const { t } = useI18n() // 国际化
  601. const maintenanceChartRef1 = ref(null)
  602. const typeData = ref([])
  603. // 配色(与图表保持一致)
  604. const statusColors = ['#2ed3df', '#34d399', '#ff6b95', '#4aa3ff', '#f59e0b', '#ef4444', '#7dd3fc']
  605. /**
  606. * 将后端返回的多种可能结构规范化为数组形式:
  607. * - 如果已经是数组则直接使用
  608. * - 如果包含 data 或 series 字段且为数组则优先使用
  609. * - 否则把对象的键值对转换为 {name, value} 数组
  610. */
  611. const normalizeTypeData = (val) => {
  612. if (Array.isArray(val)) return val
  613. if (!val || typeof val !== 'object') return []
  614. if (Array.isArray(val.data)) return val.data
  615. if (Array.isArray(val.series)) return val.series
  616. // plain object with keys -> map to array
  617. return Object.keys(val).map((k) => ({ name: k, value: val[k] }))
  618. }
  619. const legendData = computed(() => {
  620. const arr = normalizeTypeData(typeData.value)
  621. const total = arr.reduce((s, it) => s + (Number(it.value) || 0), 0)
  622. return arr.map((it, idx) => ({
  623. name: it.name,
  624. value: it.value || 0,
  625. percent: total ? ((Number(it.value) / total) * 100).toFixed(2) : '0.00',
  626. color: statusColors[idx % statusColors.length]
  627. }))
  628. })
  629. const orderSevenData = ref({})
  630. const device = ref({
  631. total: undefined,
  632. today: undefined
  633. })
  634. const maintain = ref({
  635. total: undefined,
  636. today: undefined
  637. })
  638. const by = ref({
  639. todo: undefined,
  640. finished: undefined
  641. })
  642. const fill = ref({
  643. filledCount: undefined,
  644. unfilledCount: undefined
  645. })
  646. const abnormalDevice = ref({
  647. total: undefined,
  648. today: undefined
  649. })
  650. const outliers = ref({
  651. total: undefined,
  652. today: undefined
  653. })
  654. const inspect = ref({
  655. finished: 0,
  656. todo: 0
  657. })
  658. const sparePartData = ref({
  659. xAxis: ['扳手', '水杯', '皮带', '螺丝'],
  660. series: [
  661. {
  662. name: '数量',
  663. type: 'bar',
  664. data: [10, 20, 15, 25],
  665. yAxisIndex: 0
  666. },
  667. {
  668. name: '金额',
  669. type: 'line',
  670. data: [100, 200, 150, 250],
  671. yAxisIndex: 1
  672. }
  673. ]
  674. })
  675. const sparePartDataEng = ref({
  676. xAxis: ['spanner', 'cup', 'belt', 'screw'],
  677. series: [
  678. {
  679. name: 'count',
  680. type: 'bar',
  681. data: [10, 20, 15, 25],
  682. yAxisIndex: 0
  683. },
  684. {
  685. name: 'amount',
  686. type: 'line',
  687. data: [100, 200, 150, 250],
  688. yAxisIndex: 1
  689. }
  690. ]
  691. })
  692. // 模拟巡检工单数据
  693. const totalInspectionOrders = ref(80)
  694. const completedInspectionOrders = ref(60)
  695. // 计算物料消耗数量及费用
  696. const totalMaterialCount = computed(() => {
  697. const quantitySeries = sparePartData.value.series.find((item) => item.name === '数量')
  698. return quantitySeries ? quantitySeries.data.reduce((sum, val) => sum + val, 0) : 0
  699. })
  700. const totalMaterialCost = computed(() => {
  701. const costSeries = sparePartData.value.series.find((item) => item.name === '金额')
  702. return costSeries ? costSeries.data.reduce((sum, val) => sum + val, 0) : 0
  703. })
  704. const getStats = () => {
  705. IotStatApi.getDeviceStatusCount('rd').then((res) => {
  706. typeData.value = res
  707. initDeviceStatusCharts()
  708. })
  709. IotStatApi.getOrderSeven('rd').then((res) => {
  710. orderSevenData.value = res
  711. initQxChart()
  712. })
  713. IotStatApi.getDeviceCount('rd').then((res) => {
  714. device.value = res
  715. })
  716. IotStatApi.getMaintainCount('rd').then((res) => {
  717. maintain.value = res
  718. })
  719. IotStatApi.getMaintenanceStatus('rd').then((res) => {
  720. by.value = res
  721. initMaintenanceChart()
  722. })
  723. const fillQueryParams = reactive({
  724. startTime: Date.now() - 7 * 24 * 60 * 60 * 1000, // 设置默认开始时间为 7 天前
  725. endTime: Date.now(), // 设置默认结束时间为当前时间
  726. createTime: [],
  727. deptId: null, // 选中的部门ID
  728. status: null // 填写状态
  729. })
  730. IotStatApi.getInspectStatuss(fillQueryParams, 'rd').then((res) => {
  731. inspect.value = res
  732. initInspectChart()
  733. })
  734. fillQueryParams.deptId = '163'
  735. IotStatApi.getDeptStatistics(fillQueryParams).then((res) => {
  736. fill.value = res.totalList[0] || []
  737. })
  738. const localeStore = useLocaleStore()
  739. const lang = localeStore.getCurrentLocale.lang
  740. if (lang === 'zh-CN') {
  741. initSparePartChart('数量', '金额', sparePartData)
  742. } else if (lang === 'en') {
  743. initSparePartChart('count', 'amount', sparePartDataEng)
  744. }
  745. initInspectionChart()
  746. // 计算近一周时间
  747. const end = new Date()
  748. const start = new Date()
  749. const now = new Date()
  750. // 构造:今年 1 月 1 日 00:00:00
  751. const firstDay = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0)
  752. // 转时间戳(毫秒),如需秒级时间戳,加 .getTime() / 1000
  753. start.setTime(firstDay.getTime())
  754. // 格式化日期为后端需要的格式
  755. const formatDate = (date) => {
  756. const year = date.getFullYear()
  757. const month = String(date.getMonth() + 1).padStart(2, '0')
  758. const day = String(date.getDate()).padStart(2, '0')
  759. const hours = String(date.getHours()).padStart(2, '0')
  760. const minutes = String(date.getMinutes()).padStart(2, '0')
  761. const seconds = String(date.getSeconds()).padStart(2, '0')
  762. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  763. }
  764. rateQueryParams.createTime = [formatDate(start), formatDate(end)]
  765. IotStatApi.getRdRate(rateQueryParams).then((res) => {
  766. materialTableData.value = res
  767. })
  768. }
  769. const initQxChart = () => {
  770. if (!qxRef.value) return
  771. qxInstance = echarts.init(qxRef.value)
  772. const option = {
  773. tooltip: {
  774. trigger: 'axis',
  775. axisPointer: {
  776. type: 'cross',
  777. label: {
  778. backgroundColor: '#6a7985'
  779. }
  780. }
  781. },
  782. legend: {
  783. data: orderSevenData.value.series.map((item) => item.name),
  784. top: 30,
  785. textStyle: {
  786. color: '#B6C8DA'
  787. }
  788. },
  789. grid: {
  790. left: '3%',
  791. right: '4%',
  792. bottom: '3%',
  793. containLabel: true
  794. },
  795. xAxis: {
  796. type: 'category',
  797. boundaryGap: false,
  798. data: orderSevenData.value.xAxis,
  799. axisLabel: {
  800. color: '#B6C8DA',
  801. formatter: (value) => value.split('-').join('/')
  802. },
  803. axisLine: {
  804. lineStyle: {
  805. color: '#B6C8DA' // X轴线白色半透明
  806. }
  807. }
  808. },
  809. yAxis: [
  810. {
  811. type: 'value',
  812. axisLabel: {
  813. formatter: '{value}'
  814. },
  815. axisLabel: {
  816. color: '#B6C8DA',
  817. formatter: '{value}'
  818. },
  819. splitLine: {
  820. show: true, // 显示水平网格线(默认显示)
  821. lineStyle: {
  822. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  823. color: '#457794', // 浅灰色半透明
  824. // 可选:设置线条类型(实线/虚线/点线)
  825. type: 'dashed'
  826. }
  827. },
  828. axisLine: {
  829. lineStyle: {
  830. color: '#B6C8DA'
  831. }
  832. },
  833. position: 'left' // 左侧 Y 轴
  834. },
  835. {
  836. type: 'value',
  837. axisLabel: {
  838. formatter: '{value}'
  839. },
  840. axisLabel: {
  841. color: '#B6C8DA',
  842. formatter: '{value}'
  843. },
  844. splitLine: {
  845. show: true, // 显示水平网格线(默认显示)
  846. lineStyle: {
  847. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  848. color: '#457794', // 浅灰色半透明
  849. // 可选:设置线条类型(实线/虚线/点线)
  850. type: 'dashed'
  851. }
  852. },
  853. axisLine: {
  854. lineStyle: {
  855. color: '#B6C8DA'
  856. }
  857. },
  858. position: 'right', // 右侧 Y 轴
  859. splitLine: {
  860. show: false // 隐藏右侧 Y 轴的分割线
  861. }
  862. }
  863. ],
  864. series: orderSevenData.value.series.map((item, index) => {
  865. const yAxisIndex = index < 2 ? 0 : 1
  866. return {
  867. name: item.name,
  868. type: 'line',
  869. smooth: true,
  870. symbol: 'circle',
  871. symbolSize: 8,
  872. itemStyle: {
  873. color: ['#5470c6', '#f1d209', '#e14f0f', '#91cc75'][index]
  874. },
  875. areaStyle: {
  876. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  877. { offset: 0, color: 'rgba(84,112,198,0.4)' },
  878. { offset: 1, color: 'rgba(84,112,198,0.1)' }
  879. ])
  880. },
  881. data: item.data,
  882. yAxisIndex: yAxisIndex // 指定使用的 Y 轴
  883. }
  884. })
  885. }
  886. qxInstance.setOption(option)
  887. }
  888. const initSparePartChart = (count: any, amount: any, spare: {}) => {
  889. if (!sparePartRef.value) return
  890. sparePartInstance = echarts.init(sparePartRef.value)
  891. const option = {
  892. tooltip: {
  893. trigger: 'axis',
  894. axisPointer: {
  895. type: 'cross',
  896. crossStyle: {
  897. color: '#999'
  898. }
  899. }
  900. },
  901. legend: {
  902. data: [count, amount],
  903. textStyle: {
  904. color: '#fff'
  905. }
  906. },
  907. grid: {
  908. left: '3%',
  909. right: '4%',
  910. bottom: '3%',
  911. containLabel: true
  912. },
  913. xAxis: {
  914. type: 'category',
  915. data: spare.value.xAxis,
  916. axisLabel: {
  917. color: '#B6C8DA'
  918. },
  919. axisLine: {
  920. lineStyle: {
  921. color: '#B6C8DA' // X轴线白色半透明
  922. }
  923. }
  924. },
  925. yAxis: [
  926. {
  927. type: 'value',
  928. name: count,
  929. position: 'left',
  930. axisLabel: {
  931. color: '#B6C8DA',
  932. formatter: '{value}'
  933. },
  934. splitLine: {
  935. show: true, // 显示水平网格线(默认显示)
  936. lineStyle: {
  937. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  938. color: '#457794', // 浅灰色半透明
  939. // 可选:设置线条类型(实线/虚线/点线)
  940. type: 'dashed'
  941. }
  942. },
  943. axisLine: {
  944. lineStyle: {
  945. color: '#B6C8DA'
  946. }
  947. }
  948. },
  949. {
  950. type: 'value',
  951. name: amount,
  952. position: 'right',
  953. axisLabel: {
  954. color: '#B6C8DA',
  955. formatter: '{value}'
  956. },
  957. splitLine: {
  958. show: true, // 显示水平网格线(默认显示)
  959. lineStyle: {
  960. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  961. color: '#457794', // 浅灰色半透明
  962. // 可选:设置线条类型(实线/虚线/点线)
  963. type: 'dashed'
  964. }
  965. },
  966. axisLine: {
  967. lineStyle: {
  968. color: '#B6C8DA'
  969. }
  970. },
  971. splitLine: {
  972. show: false
  973. }
  974. }
  975. ],
  976. series: spare.value.series.map((item, index) => ({
  977. name: item.name,
  978. type: item.type,
  979. data: item.data,
  980. yAxisIndex: item.yAxisIndex,
  981. itemStyle: {
  982. color: ['#6084fb', '#5aef13'][index]
  983. }
  984. }))
  985. }
  986. sparePartInstance.setOption(option)
  987. }
  988. // 设备利用率柱状图
  989. const utilizationRef = ref(null)
  990. let utilizationInstance: any = null
  991. const lastHoveredIndex = ref<number | null>(null)
  992. const initUtilizationChart = () => {
  993. if (!utilizationRef.value) return
  994. try {
  995. if (utilizationInstance) {
  996. utilizationInstance.dispose()
  997. utilizationInstance = null
  998. }
  999. } catch (e) {}
  1000. utilizationInstance = echarts.init(utilizationRef.value)
  1001. const xData = (materialTableData.value as any[]).map(
  1002. (it) => it.projectDeptName || it.dept || it.projectDept
  1003. )
  1004. const seriesData = (materialTableData.value as any[]).map((it) => {
  1005. const v = (it as any).utilizationRate
  1006. // 只保留整数部分(百分比的整数),例如 0.528 -> 52
  1007. return v == null ? 0 : Math.trunc(Number(v) * 100)
  1008. })
  1009. const option = {
  1010. tooltip: {
  1011. trigger: 'axis',
  1012. formatter: function (params) {
  1013. const p = params[0] || params
  1014. return `${p.name}: ${p.data}%`
  1015. }
  1016. },
  1017. xAxis: {
  1018. type: 'category',
  1019. data: xData,
  1020. axisLabel: { color: '#B6C8DA', rotate: 20 }
  1021. },
  1022. yAxis: {
  1023. type: 'value',
  1024. axisLabel: { formatter: '{value}%', color: '#B6C8DA' }
  1025. },
  1026. grid: { left: '3%', right: '4%', bottom: '12%', containLabel: true },
  1027. series: [
  1028. {
  1029. type: 'bar',
  1030. data: seriesData,
  1031. itemStyle: { color: statusColors[1] },
  1032. barWidth: '40%',
  1033. label: { show: true, position: 'top', formatter: '{c}%' }
  1034. }
  1035. ]
  1036. }
  1037. utilizationInstance.setOption(option)
  1038. // 鼠标悬停时展示队伍详情弹窗
  1039. try {
  1040. // 移除旧的监听,防止重复绑定
  1041. if (utilizationInstance.off) utilizationInstance.off('mouseover')
  1042. utilizationInstance.on('mouseover', (params: any) => {
  1043. try {
  1044. if (!params) return
  1045. // 仅处理柱状图系列的悬停
  1046. if (params.componentType !== 'series' || params.seriesType !== 'bar') return
  1047. const idx = params.dataIndex
  1048. if (idx == null) return
  1049. // 防止重复请求
  1050. if (lastHoveredIndex.value === idx && teamDialogVisible.value) return
  1051. lastHoveredIndex.value = idx
  1052. const row = ((materialTableData.value as any[])[idx] || {}) as any
  1053. const teamParams: any = {
  1054. deptId: row.projectDeptId || row.deptId || row.dept || row.projectDept,
  1055. createTime: rateQueryParams.createTime
  1056. }
  1057. teamDialogVisible.value = true
  1058. teamTableData.value = []
  1059. IotStatApi.getRdTeamRate(teamParams).then((res) => {
  1060. teamTableData.value = res
  1061. })
  1062. } catch (e) {}
  1063. })
  1064. } catch (e) {}
  1065. window.addEventListener('resize', () => {
  1066. try {
  1067. utilizationInstance && utilizationInstance.resize()
  1068. } catch (e) {}
  1069. })
  1070. }
  1071. watch(
  1072. materialTableData,
  1073. () => {
  1074. nextTick(() => initUtilizationChart())
  1075. },
  1076. { deep: true }
  1077. )
  1078. onMounted(() => {
  1079. initUtilizationChart()
  1080. })
  1081. onUnmounted(() => {
  1082. try {
  1083. if (utilizationInstance) {
  1084. try {
  1085. if (utilizationInstance.off) utilizationInstance.off('mouseover')
  1086. } catch (e) {}
  1087. utilizationInstance.dispose()
  1088. utilizationInstance = null
  1089. }
  1090. } catch (e) {}
  1091. })
  1092. const initInspectChart = () => {
  1093. if (!inspectChartRef.value) return
  1094. inspectChartInstance = echarts.init(inspectChartRef.value)
  1095. const completionRate =
  1096. (inspect.value.finished / (inspect.value.finished + inspect.value.todo)) * 100
  1097. // debugger
  1098. const option = {
  1099. tooltip: {
  1100. trigger: 'item'
  1101. },
  1102. legend: {
  1103. orient: 'horizontal', // 水平排列图例项
  1104. bottom: '0%', // 放置在底部
  1105. icon: 'circle',
  1106. textStyle: {
  1107. color: '#B6C8DA'
  1108. }
  1109. },
  1110. series: [
  1111. {
  1112. type: 'pie',
  1113. radius: ['40%', '70%'],
  1114. label: {
  1115. show: false,
  1116. position: 'outside'
  1117. },
  1118. emphasis: {
  1119. label: {
  1120. color: '#B6C8DA',
  1121. show: true,
  1122. fontSize: 15,
  1123. fontWeight: 'bold'
  1124. }
  1125. },
  1126. labelLine: {
  1127. show: true
  1128. },
  1129. // itemStyle: {
  1130. // color: ['#e4a317', '#5aef13']
  1131. // },
  1132. data: [
  1133. { name: '完成率', value: completionRate.toFixed(2) },
  1134. { name: '未完成率', value: 100 - completionRate.toFixed(2) }
  1135. ]
  1136. }
  1137. ]
  1138. }
  1139. inspectChartInstance.setOption(option)
  1140. }
  1141. const initMaintenanceChart = () => {
  1142. if (!maintenanceChartRef.value) return
  1143. maintenanceChartInstance = echarts.init(maintenanceChartRef.value)
  1144. const completionRate = (by.value.finished / (by.value.finished + by.value.todo)) * 100
  1145. // debugger
  1146. const option = {
  1147. tooltip: {
  1148. trigger: 'item'
  1149. },
  1150. legend: {
  1151. orient: 'horizontal', // 水平排列图例项
  1152. bottom: '0%', // 放置在底部
  1153. icon: 'circle',
  1154. textStyle: {
  1155. color: '#B6C8DA'
  1156. }
  1157. },
  1158. series: [
  1159. {
  1160. type: 'pie',
  1161. radius: ['40%', '70%'],
  1162. label: {
  1163. show: false,
  1164. position: 'outside'
  1165. },
  1166. emphasis: {
  1167. label: {
  1168. color: '#B6C8DA',
  1169. show: true,
  1170. fontSize: 15,
  1171. fontWeight: 'bold'
  1172. }
  1173. },
  1174. labelLine: {
  1175. show: true
  1176. },
  1177. data: [
  1178. { name: '完成率', value: completionRate.toFixed(2) },
  1179. { name: '未完成率', value: 100 - completionRate.toFixed(2) }
  1180. ]
  1181. }
  1182. ]
  1183. }
  1184. maintenanceChartInstance.setOption(option)
  1185. }
  1186. const initInspectionChart = () => {
  1187. if (!inspectionChartRef.value) return
  1188. inspectionChartInstance = echarts.init(inspectionChartRef.value)
  1189. const completionRate = (completedInspectionOrders.value / totalInspectionOrders.value) * 100
  1190. const option = {
  1191. series: [
  1192. {
  1193. type: 'pie',
  1194. radius: ['50%', '80%'],
  1195. data: [
  1196. { value: completionRate, name: '完成率' },
  1197. { value: 100 - completionRate, name: '未完成率' }
  1198. ]
  1199. }
  1200. ]
  1201. }
  1202. inspectionChartInstance.setOption(option)
  1203. }
  1204. /** 初始化图表 */
  1205. const initDeviceStatusCharts = () => {
  1206. if (!statusChartRef.value) return
  1207. // dispose old instance
  1208. try {
  1209. if (statusChartInstance) {
  1210. statusChartInstance.dispose()
  1211. statusChartInstance = null
  1212. }
  1213. } catch (e) {
  1214. // ignore
  1215. }
  1216. statusChartInstance = echarts.init(statusChartRef.value)
  1217. const data = normalizeTypeData(typeData.value)
  1218. const option = {
  1219. color: statusColors,
  1220. tooltip: {
  1221. trigger: 'item',
  1222. formatter: '{b}: {c} ({d}%)'
  1223. },
  1224. series: [
  1225. {
  1226. name: '',
  1227. type: 'pie',
  1228. radius: ['38%', '58%'],
  1229. center: ['50%', '30%'],
  1230. avoidLabelOverlap: false,
  1231. label: { show: false },
  1232. labelLine: { show: false },
  1233. data: data.map((it) => ({ name: it.name, value: it.value }))
  1234. }
  1235. ]
  1236. }
  1237. statusChartInstance.setOption(option)
  1238. }
  1239. // 月度工作量表数据
  1240. const monthData = ref<any[]>([
  1241. {
  1242. month: '1月',
  1243. y2025_fractures: 49,
  1244. y2025_layers: 102,
  1245. y2025_pump_trips: 621,
  1246. y2025_oil_wells: 17,
  1247. y2024_fractures: 23,
  1248. y2024_layers: 42,
  1249. y2024_pump_trips: 347,
  1250. y2024_oil_wells: 9
  1251. },
  1252. {
  1253. month: '2月',
  1254. y2025_fractures: 30,
  1255. y2025_layers: 52,
  1256. y2025_pump_trips: 438,
  1257. y2025_oil_wells: 15,
  1258. y2024_fractures: 14,
  1259. y2024_layers: 41,
  1260. y2024_pump_trips: 46,
  1261. y2024_oil_wells: 11
  1262. },
  1263. {
  1264. month: '3月',
  1265. y2025_fractures: 48,
  1266. y2025_layers: 127,
  1267. y2025_pump_trips: 326,
  1268. y2025_oil_wells: 30,
  1269. y2024_fractures: 42,
  1270. y2024_layers: 58,
  1271. y2024_pump_trips: 321,
  1272. y2024_oil_wells: 17
  1273. },
  1274. {
  1275. month: '4月',
  1276. y2025_fractures: 49,
  1277. y2025_layers: 130,
  1278. y2025_pump_trips: 1203,
  1279. y2025_oil_wells: 45,
  1280. y2024_fractures: 32,
  1281. y2024_layers: 184,
  1282. y2024_pump_trips: 1046,
  1283. y2024_oil_wells: 30
  1284. },
  1285. {
  1286. month: '5月',
  1287. y2025_fractures: 13,
  1288. y2025_layers: 76,
  1289. y2025_pump_trips: 701,
  1290. y2025_oil_wells: 18,
  1291. y2024_fractures: 73,
  1292. y2024_layers: 133,
  1293. y2024_pump_trips: 414,
  1294. y2024_oil_wells: 24
  1295. },
  1296. {
  1297. month: '6月',
  1298. y2025_fractures: 34,
  1299. y2025_layers: 187,
  1300. y2025_pump_trips: 831,
  1301. y2025_oil_wells: 30,
  1302. y2024_fractures: 29,
  1303. y2024_layers: 113,
  1304. y2024_pump_trips: 750,
  1305. y2024_oil_wells: 35
  1306. },
  1307. {
  1308. month: '7月',
  1309. y2025_fractures: 30,
  1310. y2025_layers: 230,
  1311. y2025_pump_trips: 1157,
  1312. y2025_oil_wells: 51,
  1313. y2024_fractures: 24,
  1314. y2024_layers: 47,
  1315. y2024_pump_trips: 326,
  1316. y2024_oil_wells: 17
  1317. },
  1318. {
  1319. month: '8月',
  1320. y2025_fractures: 59,
  1321. y2025_layers: 218,
  1322. y2025_pump_trips: 1163,
  1323. y2025_oil_wells: 12,
  1324. y2024_fractures: 36,
  1325. y2024_layers: 121,
  1326. y2024_pump_trips: 1107,
  1327. y2024_oil_wells: 26
  1328. },
  1329. {
  1330. month: '9月',
  1331. y2025_fractures: 48,
  1332. y2025_layers: 80,
  1333. y2025_pump_trips: 440,
  1334. y2025_oil_wells: 39,
  1335. y2024_fractures: 35,
  1336. y2024_layers: 162,
  1337. y2024_pump_trips: 928,
  1338. y2024_oil_wells: 36
  1339. },
  1340. {
  1341. month: '10月',
  1342. y2025_fractures: 45,
  1343. y2025_layers: 99,
  1344. y2025_pump_trips: 697,
  1345. y2025_oil_wells: 49,
  1346. y2024_fractures: 36,
  1347. y2024_layers: 116,
  1348. y2024_pump_trips: 891,
  1349. y2024_oil_wells: 33
  1350. },
  1351. {
  1352. month: '11月',
  1353. y2025_fractures: null,
  1354. y2025_layers: null,
  1355. y2025_pump_trips: null,
  1356. y2025_oil_wells: null,
  1357. y2024_fractures: 19,
  1358. y2024_layers: 102,
  1359. y2024_pump_trips: 582,
  1360. y2024_oil_wells: 36
  1361. },
  1362. {
  1363. month: '12月',
  1364. y2025_fractures: null,
  1365. y2025_layers: null,
  1366. y2025_pump_trips: null,
  1367. y2025_oil_wells: null,
  1368. y2024_fractures: 51,
  1369. y2024_layers: 186,
  1370. y2024_pump_trips: 971,
  1371. y2024_oil_wells: 32
  1372. }
  1373. ])
  1374. // 计算同比差值(2025 - 2024),保留 null 的情况
  1375. monthData.value.forEach((row) => {
  1376. const f2025 = row.y2025_fractures
  1377. const f2024 = row.y2024_fractures
  1378. row.diff_fractures = f2025 == null || f2024 == null ? null : f2025 - f2024
  1379. const l2025 = row.y2025_layers
  1380. const l2024 = row.y2024_layers
  1381. row.diff_layers = l2025 == null || l2024 == null ? null : l2025 - l2024
  1382. const p2025 = row.y2025_pump_trips
  1383. const p2024 = row.y2024_pump_trips
  1384. row.diff_pump_trips = p2025 == null || p2024 == null ? null : p2025 - p2024
  1385. const o2025 = row.y2025_oil_wells
  1386. const o2024 = row.y2024_oil_wells
  1387. row.diff_oil_wells = o2025 == null || o2024 == null ? null : o2025 - o2024
  1388. })
  1389. // 表格合计方法(稳健实现,避免把图表配置或数据插入此处)
  1390. const tableSummary = ({ columns, data }: any) => {
  1391. const sums: any[] = []
  1392. columns.forEach((column: any, index: number) => {
  1393. if (index === 0) {
  1394. sums[index] = '合计'
  1395. return
  1396. }
  1397. const property = column.property
  1398. if (!property) {
  1399. sums[index] = ''
  1400. return
  1401. }
  1402. let total = 0
  1403. let hasValue = false
  1404. data.forEach((row: any) => {
  1405. const val = row[property]
  1406. if (val != null && !isNaN(Number(val))) {
  1407. total += Number(val)
  1408. hasValue = true
  1409. }
  1410. })
  1411. // 对原值占比列(orig_ratio)在国内表中不显示合计,留空
  1412. if (data === domesticData.value && property === 'orig_ratio') {
  1413. sums[index] = ''
  1414. } else {
  1415. sums[index] = hasValue ? total : ''
  1416. }
  1417. })
  1418. return sums
  1419. }
  1420. let projectDataDialog = ref(false)
  1421. let projectDataDialog2 = ref(false)
  1422. let projectDataDialog3 = ref(false)
  1423. // projectDataRowClick
  1424. const projectDataRowClick = (row, column, event) => {
  1425. console.log('点击的行数据:', row)
  1426. if (row.dept === '国内') {
  1427. // 显示国内表格
  1428. projectDataDialog.value = true
  1429. } else if (row.dept === '伊拉克') {
  1430. // 显示伊拉克表格
  1431. projectDataDialog2.value = true
  1432. } else if (row.dept === '利比亚') {
  1433. // 显示利比亚表格
  1434. projectDataDialog3.value = true
  1435. }
  1436. }
  1437. const domesticData = ref<any[]>([
  1438. {
  1439. index: 1,
  1440. dept: '公摊',
  1441. count: 13,
  1442. orig_value: 1506.88,
  1443. net_value: 559.95,
  1444. orig_ratio: '2.77%'
  1445. },
  1446. {
  1447. index: 2,
  1448. dept: '新疆项目部',
  1449. count: 58,
  1450. orig_value: 5118.1,
  1451. net_value: 1182.49,
  1452. orig_ratio: '9.40%'
  1453. },
  1454. {
  1455. index: 3,
  1456. dept: '青海项目',
  1457. count: 33,
  1458. orig_value: 7004.23,
  1459. net_value: 1758.8,
  1460. orig_ratio: '12.86%'
  1461. },
  1462. {
  1463. index: 4,
  1464. dept: '东部项目部',
  1465. count: 49,
  1466. orig_value: 5273.54,
  1467. net_value: 683.58,
  1468. orig_ratio: '9.68%'
  1469. },
  1470. {
  1471. index: 5,
  1472. dept: '西南连油项目部',
  1473. count: 24,
  1474. orig_value: 4059.36,
  1475. net_value: 743.24,
  1476. orig_ratio: '7.45%'
  1477. },
  1478. {
  1479. index: 6,
  1480. dept: '西南压裂项目部',
  1481. count: 47,
  1482. orig_value: 14591.62,
  1483. net_value: 6030.84,
  1484. orig_ratio: '26.79%'
  1485. },
  1486. {
  1487. index: 7,
  1488. dept: '伊拉克 哈法亚连油',
  1489. count: 120,
  1490. orig_value: 694.78,
  1491. net_value: 91.26,
  1492. orig_ratio: '9.07%'
  1493. },
  1494. {
  1495. index: 8,
  1496. dept: '伊拉克 哈法亚压裂',
  1497. count: 132,
  1498. orig_value: 1008.92,
  1499. net_value: 575.91,
  1500. orig_ratio: '13.17%%'
  1501. },
  1502. {
  1503. index: 9,
  1504. dept: '伊拉克 B9增产',
  1505. count: 27,
  1506. orig_value: 304.72,
  1507. net_value: 124.1,
  1508. orig_ratio: '3.98%'
  1509. },
  1510. {
  1511. index: 10,
  1512. dept: '利比亚连油8队',
  1513. count: 22,
  1514. orig_value: 2025.52,
  1515. net_value: 1731.79,
  1516. orig_ratio: '4.85%'
  1517. }
  1518. ])
  1519. // 初始化 国内设备分布饼图相关(放在 domesticData 声明后)
  1520. const domesticChartRef = ref(null)
  1521. let domesticInstance: any = null
  1522. const handleDomesticResize = () => {
  1523. try {
  1524. if (domesticInstance) domesticInstance.resize()
  1525. } catch (e) {}
  1526. }
  1527. const initDomesticChart = () => {
  1528. if (!domesticChartRef.value) return
  1529. try {
  1530. if (domesticInstance) {
  1531. domesticInstance.dispose()
  1532. domesticInstance = null
  1533. }
  1534. } catch (e) {}
  1535. domesticInstance = echarts.init(domesticChartRef.value)
  1536. const data = domesticData.value.map((it) => ({
  1537. name: it.dept,
  1538. value: Number(it.orig_value) || 0,
  1539. orig_ratio: it.orig_ratio || ''
  1540. }))
  1541. const option = {
  1542. tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
  1543. legend: { show: false },
  1544. color: statusColors,
  1545. series: [
  1546. {
  1547. name: '国内设备价值',
  1548. type: 'pie',
  1549. // 使用实心扇形(非环形)
  1550. radius: ['0%', '70%'],
  1551. center: ['50%', '50%'],
  1552. avoidLabelOverlap: false,
  1553. label: {
  1554. show: true,
  1555. position: 'outside',
  1556. formatter: function (params) {
  1557. const val = Number(params.value) || 0
  1558. const formatted = val.toLocaleString(undefined, {
  1559. minimumFractionDigits: 2,
  1560. maximumFractionDigits: 2
  1561. })
  1562. // 优先使用后端提供的 orig_ratio 字段(如 "22.87%"),若不存在则退回计算值
  1563. const ratio =
  1564. params.data && params.data.orig_ratio
  1565. ? params.data.orig_ratio
  1566. : `${Math.round(params.percent || 0)}%`
  1567. return `${formatted}, ${ratio}`
  1568. },
  1569. color: '#fff',
  1570. fontSize: 12
  1571. },
  1572. labelLine: { length: 18, length2: 6 },
  1573. data,
  1574. color: [
  1575. '#5b9bd5',
  1576. '#ed7d31',
  1577. '#a5a5a5',
  1578. '#ffc000',
  1579. '#4472c4',
  1580. '#70ad47',
  1581. '#255e91',
  1582. '#9e480e',
  1583. '#636363',
  1584. '#997300'
  1585. ]
  1586. }
  1587. ]
  1588. }
  1589. domesticInstance.setOption(option)
  1590. window.addEventListener('resize', handleDomesticResize)
  1591. }
  1592. // 在 domesticData 变化时重绘
  1593. watch(
  1594. domesticData,
  1595. () => {
  1596. nextTick(() => initDomesticChart())
  1597. },
  1598. { deep: true }
  1599. )
  1600. onMounted(() => {
  1601. // 初始绘制
  1602. initDomesticChart()
  1603. })
  1604. onUnmounted(() => {
  1605. try {
  1606. if (domesticInstance) {
  1607. domesticInstance.dispose()
  1608. domesticInstance = null
  1609. }
  1610. } catch (e) {}
  1611. try {
  1612. window.removeEventListener('resize', handleDomesticResize)
  1613. } catch (e) {}
  1614. })
  1615. const iraqData = ref<any[]>([
  1616. {
  1617. index: 1,
  1618. dept: '伊拉克 哈法亚连油',
  1619. count: 120,
  1620. orig_value_usd: 694.78,
  1621. net_value_usd: 94.44,
  1622. orig_ratio: '8.02%'
  1623. },
  1624. {
  1625. index: 2,
  1626. dept: '伊拉克 哈法亚压裂',
  1627. count: 132,
  1628. orig_value_usd: 1008.92,
  1629. net_value_usd: 587.07,
  1630. orig_ratio: '11.65%'
  1631. },
  1632. {
  1633. index: 3,
  1634. dept: '伊拉克 B9增产',
  1635. count: 27,
  1636. orig_value_usd: 304.72,
  1637. net_value_usd: 128.62,
  1638. orig_ratio: '3.52%'
  1639. }
  1640. ])
  1641. const iraqTableData = computed(() => {
  1642. const base = iraqData.value.slice()
  1643. base.push({
  1644. index: '',
  1645. dept: '合计',
  1646. count: 279,
  1647. orig_value: Number(279),
  1648. orig_value_usd: Number(2008.41),
  1649. net_value_usd: Number(810.13),
  1650. orig_ratio: ''
  1651. })
  1652. base.push({
  1653. index: '',
  1654. dept: '折算RMB合计',
  1655. count: '',
  1656. orig_value: Number(61574.3),
  1657. orig_value_usd: Number(14279.83),
  1658. net_value_usd: Number(5760.03),
  1659. orig_ratio: '23.19%'
  1660. })
  1661. return base
  1662. })
  1663. // 折算RMB合计(数值)
  1664. const iraqRmbTotal = ref(14279.83)
  1665. const libyaData = ref<any[]>([
  1666. {
  1667. index: 1,
  1668. dept: '利比亚 连油8队',
  1669. count: 22,
  1670. orig_value: 2025.52,
  1671. net_value: 1961.69,
  1672. orig_ratio: ''
  1673. }
  1674. ])
  1675. const libyaRmbTotal = ref(2641.07)
  1676. const libyaRmbNet = ref(2557.84)
  1677. const libyaTableData = computed(() => {
  1678. const base = libyaData.value.slice()
  1679. base.push({
  1680. index: '',
  1681. dept: '折算RMB合计',
  1682. count: '',
  1683. orig_value: Number(libyaRmbTotal.value),
  1684. net_value: Number(libyaRmbNet.value),
  1685. orig_ratio: '4.29%'
  1686. })
  1687. base.push({
  1688. index: '',
  1689. dept: '国内外合计',
  1690. count: 525,
  1691. orig_value: Number(61574.3),
  1692. net_value: Number(18256.63),
  1693. orig_ratio: ''
  1694. })
  1695. return base
  1696. })
  1697. // 行样式:合计行与折算RMB合计高亮
  1698. const tableRowClass = (row: any) => {
  1699. if (!row) return ''
  1700. if (row.dept === '合计') return 'summary-row'
  1701. if (row.dept && typeof row.dept === 'string' && row.dept.indexOf('折算') !== -1) return 'rmb-row'
  1702. return ''
  1703. }
  1704. /** 初始化 **/
  1705. onMounted(async () => {
  1706. loading.value = true
  1707. await Promise.all([getStats()])
  1708. loading.value = false
  1709. })
  1710. </script>
  1711. <style lang="scss" scoped>
  1712. @media (width <= 768px) {
  1713. .page-container {
  1714. padding: 10px;
  1715. }
  1716. }
  1717. @media (width <= 520px) {
  1718. .status-legend-item {
  1719. min-width: 100%;
  1720. }
  1721. .status-legend {
  1722. justify-content: flex-start;
  1723. max-height: none;
  1724. overflow: visible;
  1725. }
  1726. }
  1727. ::v-deep .el-table,
  1728. ::v-deep .el-table__expanded-cell {
  1729. background-color: transparent !important;
  1730. }
  1731. /* 表格内背景颜色 */
  1732. ::v-deep .el-table tr,
  1733. ::v-deep .el-table td {
  1734. background-color: transparent !important;
  1735. }
  1736. ::v-deep .el-table__footer {
  1737. color: #fff !important;
  1738. }
  1739. ::v-deep .el-table__footer-wrapper .is-leaf {
  1740. color: #fff !important;
  1741. }
  1742. .summary {
  1743. .el-col {
  1744. margin-bottom: 1rem;
  1745. }
  1746. }
  1747. .stat-card {
  1748. width: 48%;
  1749. }
  1750. .page-container {
  1751. min-height: 100vh;
  1752. padding: 20px;
  1753. background-color: #3a6fa3;
  1754. }
  1755. .summary {
  1756. margin-bottom: 20px;
  1757. }
  1758. ::v-deep .chart-card {
  1759. background-color: rgb(0 0 0 / 30%);
  1760. border: none;
  1761. border-radius: 8px;
  1762. box-shadow: 0 2px 12px rgb(0 0 0 / 50%);
  1763. transition: all 0.3s ease;
  1764. &:hover {
  1765. box-shadow: 0 4px 16px rgb(0 0 0 / 8%);
  1766. }
  1767. }
  1768. // 安全生产天数卡片样式
  1769. .safety-days-card {
  1770. .safety-days-content {
  1771. position: relative;
  1772. display: flex;
  1773. height: 150px;
  1774. flex-direction: column;
  1775. align-items: center;
  1776. justify-content: center;
  1777. .days-number {
  1778. font-size: 58px;
  1779. font-weight: bold;
  1780. line-height: 1;
  1781. color: darkorange;
  1782. transition: all 0.3s ease;
  1783. }
  1784. .days-number:hover {
  1785. transform: scale(1.05);
  1786. }
  1787. .days-label {
  1788. margin-top: 8px;
  1789. font-size: 20px;
  1790. color: white;
  1791. }
  1792. .safety-desc {
  1793. position: absolute;
  1794. bottom: 10px;
  1795. width: 90%;
  1796. font-size: 14px;
  1797. color: #999;
  1798. text-align: center;
  1799. }
  1800. }
  1801. }
  1802. ::v-deep .el-card__header {
  1803. padding-bottom: 0;
  1804. border-bottom: none !important;
  1805. }
  1806. .table-container {
  1807. height: 420px;
  1808. padding: 16px;
  1809. overflow: auto;
  1810. box-sizing: border-box;
  1811. // 滚动条样式优化
  1812. &::-webkit-scrollbar {
  1813. width: 6px;
  1814. height: 6px;
  1815. }
  1816. &::-webkit-scrollbar-thumb {
  1817. background-color: rgb(255 255 255 / 20%);
  1818. border-radius: 3px;
  1819. }
  1820. &::-webkit-scrollbar-track {
  1821. background-color: transparent;
  1822. }
  1823. }
  1824. // 修复表格hover样式
  1825. ::v-deep .el-table__row:hover > td {
  1826. background-color: rgb(255 255 255 / 5%) !important;
  1827. }
  1828. .custom-scroll-dialog {
  1829. /* 可选:限制对话框整体最大高度(避免超出屏幕) */
  1830. max-height: 90vh;
  1831. overflow: hidden; /* 隐藏整体溢出,避免出现双重滚动条 */
  1832. }
  1833. /* 滚动内容容器:核心样式 */
  1834. .dialog-scroll-content {
  1835. max-height: 60vh; /* 固定最大高度(可根据需求调整,如500px) */
  1836. padding-right: 8px; /* 避免滚动条遮挡内容(可选) */
  1837. overflow-y: auto; /* 垂直方向溢出时显示滚动条 */
  1838. }
  1839. /* 优化滚动条样式(可选,提升UI体验) */
  1840. .dialog-scroll-content::-webkit-scrollbar {
  1841. width: 6px; /* 滚动条宽度 */
  1842. }
  1843. .dialog-scroll-content::-webkit-scrollbar-thumb {
  1844. background-color: #e5e7eb; /* 滚动条滑块颜色 */
  1845. border-radius: 3px; /* 滚动条圆角 */
  1846. }
  1847. .dialog-scroll-content::-webkit-scrollbar-thumb:hover {
  1848. background-color: #d1d5db; /* hover时滑块颜色 */
  1849. }
  1850. .custom-table :deep .el-table__row {
  1851. height: 50px !important; /* 高度根据需求调整 */
  1852. }
  1853. /* 设备状态图例自适应样式 */
  1854. .status-legend {
  1855. display: flex;
  1856. width: 100%;
  1857. max-height: 90px; /* 限制高度,超出显示滚动 */
  1858. padding: 6px 0;
  1859. overflow-y: auto;
  1860. box-sizing: border-box;
  1861. flex-wrap: wrap;
  1862. justify-content: center;
  1863. gap: 8px;
  1864. }
  1865. .status-legend-item {
  1866. display: flex;
  1867. max-width: 100%;
  1868. min-width: 120px;
  1869. padding: 6px 10px;
  1870. box-sizing: border-box;
  1871. align-items: center;
  1872. justify-content: space-between;
  1873. gap: 12px;
  1874. }
  1875. .status-legend-left {
  1876. display: flex;
  1877. align-items: center;
  1878. gap: 8px;
  1879. min-width: 0;
  1880. }
  1881. .status-legend-color {
  1882. display: inline-block;
  1883. width: 12px;
  1884. height: 12px;
  1885. border-radius: 50%;
  1886. flex: 0 0 12px;
  1887. }
  1888. .status-legend-name {
  1889. max-width: calc(100% - 60px);
  1890. overflow: hidden;
  1891. color: #fff;
  1892. text-overflow: ellipsis;
  1893. white-space: nowrap;
  1894. }
  1895. .status-legend-right {
  1896. display: flex;
  1897. align-items: center;
  1898. gap: 8px;
  1899. flex-shrink: 0;
  1900. }
  1901. .status-legend-value {
  1902. font-weight: 700;
  1903. color: #fff;
  1904. }
  1905. .status-legend-percent {
  1906. color: #fff;
  1907. }
  1908. /* 最外层透明 */
  1909. </style>