index.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. <template>
  2. <el-row :gutter="20">
  3. <el-col :span="4" :xs="24">
  4. <ContentWrap class="h-1/1">
  5. <DeptTree2 :deptId="rootDeptId" @node-click="handleDeptNodeClick" />
  6. </ContentWrap>
  7. </el-col>
  8. <el-col :span="20" :xs="24">
  9. <ContentWrap>
  10. <!-- 搜索工作栏 -->
  11. <el-form
  12. class="-mb-15px"
  13. :model="queryParams"
  14. ref="queryFormRef"
  15. :inline="true"
  16. label-width="68px"
  17. >
  18. <el-form-item label="项目" prop="contractName">
  19. <el-input
  20. v-model="queryParams.contractName"
  21. placeholder="请输入项目"
  22. clearable
  23. @keyup.enter="handleQuery"
  24. class="!w-240px"
  25. />
  26. </el-form-item>
  27. <el-form-item label="任务" prop="taskName">
  28. <el-input
  29. v-model="queryParams.taskName"
  30. placeholder="请输入任务"
  31. clearable
  32. @keyup.enter="handleQuery"
  33. class="!w-240px"
  34. />
  35. </el-form-item>
  36. <el-form-item label="创建时间" prop="createTime">
  37. <el-date-picker
  38. v-model="queryParams.createTime"
  39. value-format="YYYY-MM-DD HH:mm:ss"
  40. type="daterange"
  41. start-placeholder="开始日期"
  42. end-placeholder="结束日期"
  43. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  44. :shortcuts="rangeShortcuts"
  45. class="!w-220px"
  46. />
  47. </el-form-item>
  48. <el-form-item>
  49. <el-button @click="handleQuery"
  50. ><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button
  51. >
  52. <el-button @click="resetQuery"
  53. ><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button
  54. >
  55. <el-button
  56. type="primary"
  57. plain
  58. @click="openForm('create')"
  59. v-hasPermi="['pms:iot-rh-daily-report:create']"
  60. >
  61. <Icon icon="ep:plus" class="mr-5px" /> 新增
  62. </el-button>
  63. <el-button
  64. type="success"
  65. plain
  66. @click="handleExport"
  67. :loading="exportLoading"
  68. v-hasPermi="['pms:iot-rh-daily-report:export']"
  69. >
  70. <Icon icon="ep:download" class="mr-5px" /> 导出
  71. </el-button>
  72. </el-form-item>
  73. </el-form>
  74. </ContentWrap>
  75. <!-- 数据统计区域 -->
  76. <ContentWrap class="mb-15px">
  77. <div class="statistics-container">
  78. <div class="stat-item" :style="{ color: totalColor }">
  79. <span>总数:</span>
  80. <span>{{ statistics.total || '-' }}</span>
  81. </div>
  82. <div class="stat-item" :style="{ color: filledColor }">
  83. <span>已填报:</span>
  84. <span>{{ statistics.filled || '-' }}</span>
  85. </div>
  86. <div class="stat-item" :style="{ color: unFilledColor }">
  87. <span>未填报:</span>
  88. <span
  89. class="unfilled-link"
  90. @click="openUnfilledDialog"
  91. :class="{ disabled: !queryParams.createTime || queryParams.createTime.length === 0 }"
  92. >
  93. {{ statistics.unFilled || '-' }}
  94. </span>
  95. </div>
  96. <div class="stat-item" :style="{ color: '#0099CC' }">
  97. <span>累计注水量(方):</span>
  98. <span>{{ statistics.totalWaterInjection || '-' }}</span>
  99. </div>
  100. <div class="stat-item" :style="{ color: '#FF9900' }">
  101. <span>累计注气量(万方):</span>
  102. <span>{{ statistics.totalGasInjection || '-' }}</span>
  103. </div>
  104. </div>
  105. </ContentWrap>
  106. <ContentWrap class="mb-15px">
  107. <div class="color-legend">
  108. <div class="legend-item">
  109. <span class="color-indicator red"></span>
  110. <span
  111. >运行时效=当日注气量/产能&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;超过120%红色预警</span
  112. >
  113. </div>
  114. <div class="legend-item">
  115. <span class="color-indicator orange"></span>
  116. <span
  117. >当日注气时间+当日注水时间+非生产时间=24H&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;否则橙色预警</span
  118. >
  119. </div>
  120. </div>
  121. </ContentWrap>
  122. <!-- 列表 -->
  123. <ContentWrap ref="tableContainerRef">
  124. <div class="table-container">
  125. <el-table
  126. ref="tableRef"
  127. v-loading="loading"
  128. :data="list"
  129. :stripe="true"
  130. :style="{ width: '100%' }"
  131. max-height="600"
  132. :cell-style="cellStyle"
  133. show-overflow-tooltip
  134. border
  135. >
  136. <el-table-column :label="t('iotDevice.serial')" width="56px" align="center">
  137. <template #default="scope">
  138. {{ scope.$index + 1 }}
  139. </template>
  140. </el-table-column>
  141. <el-table-column
  142. label="日期"
  143. align="center"
  144. prop="createTime"
  145. :formatter="dateFormatter"
  146. :min-width="columnWidths.createTime.width"
  147. resizable
  148. />
  149. <el-table-column
  150. label="施工队伍"
  151. align="center"
  152. prop="deptName"
  153. :min-width="columnWidths.deptName.width"
  154. resizable
  155. />
  156. <el-table-column
  157. label="项目"
  158. align="center"
  159. prop="contractName"
  160. class-name="contract-name-column"
  161. :min-width="columnWidths.contractName.width"
  162. resizable
  163. />
  164. <el-table-column
  165. label="任务"
  166. align="center"
  167. prop="taskName"
  168. :min-width="columnWidths.taskName.width"
  169. resizable
  170. />
  171. <!-- <el-table-column label="施工状态" align="center" prop="constructionStatus" /> -->
  172. <el-table-column
  173. :label="t('project.status')"
  174. align="center"
  175. prop="constructionStatus"
  176. :min-width="columnWidths.constructionStatus.width"
  177. resizable
  178. >
  179. <template #default="scope">
  180. <dict-tag
  181. :type="DICT_TYPE.PMS_PROJECT_TASK_SCHEDULE"
  182. :value="scope.row.constructionStatus"
  183. />
  184. </template>
  185. </el-table-column>
  186. <el-table-column
  187. label="搬迁安装天数"
  188. align="center"
  189. prop="relocationDays"
  190. :formatter="relocationDaysFormatter"
  191. :min-width="columnWidths.relocationDays.width"
  192. resizable
  193. />
  194. <el-table-column
  195. label="设计注气量(万方)"
  196. align="center"
  197. prop="designInjection"
  198. :min-width="columnWidths.designInjection.width"
  199. resizable
  200. />
  201. <el-table-column
  202. label="运行时效"
  203. align="center"
  204. prop="transitTime"
  205. :formatter="percentageFormatter"
  206. :min-width="columnWidths.transitTime.width"
  207. resizable
  208. />
  209. <el-table-column label="当日" align="center">
  210. <el-table-column
  211. label="注气量(万方)"
  212. align="center"
  213. prop="dailyGasInjection"
  214. :formatter="gasInjectionFormatter"
  215. :min-width="columnWidths.dailyGasInjection.width"
  216. resizable
  217. />
  218. <el-table-column
  219. label="注水量(方)"
  220. align="center"
  221. prop="dailyWaterInjection"
  222. :min-width="columnWidths.dailyWaterInjection.width"
  223. resizable
  224. />
  225. <el-table-column
  226. label="注气时间(H)"
  227. align="center"
  228. prop="dailyInjectGasTime"
  229. :min-width="columnWidths.dailyInjectGasTime.width"
  230. resizable
  231. />
  232. <el-table-column
  233. label="注水时间(H)"
  234. align="center"
  235. prop="dailyInjectWaterTime"
  236. :min-width="columnWidths.dailyInjectWaterTime.width"
  237. resizable
  238. />
  239. <el-table-column
  240. label="用电量(kWh)"
  241. align="center"
  242. prop="dailyPowerUsage"
  243. :min-width="columnWidths.dailyPowerUsage.width"
  244. resizable
  245. />
  246. <el-table-column
  247. label="油耗(L)"
  248. align="center"
  249. prop="dailyOilUsage"
  250. :min-width="columnWidths.dailyOilUsage.width"
  251. resizable
  252. />
  253. </el-table-column>
  254. <el-table-column
  255. label="非生产时间(H)"
  256. align="center"
  257. prop="nonProductionTime"
  258. :min-width="columnWidths.nonProductionTime.width"
  259. resizable
  260. />
  261. <el-table-column
  262. :label="t('project.nptReason')"
  263. align="center"
  264. prop="nptReason"
  265. :min-width="columnWidths.nptReason.width"
  266. resizable
  267. >
  268. <template #default="scope">
  269. <dict-tag :type="DICT_TYPE.PMS_PROJECT_NPT_REASON" :value="scope.row.nptReason" />
  270. </template>
  271. </el-table-column>
  272. <el-table-column
  273. label="施工开始日期"
  274. align="center"
  275. prop="constructionStartDate"
  276. :formatter="dateFormatter"
  277. :min-width="columnWidths.constructionStartDate.width"
  278. resizable
  279. />
  280. <el-table-column
  281. label="施工结束日期"
  282. align="center"
  283. prop="constructionEndDate"
  284. :formatter="dateFormatter"
  285. :min-width="columnWidths.constructionEndDate.width"
  286. resizable
  287. />
  288. <el-table-column
  289. label="生产动态"
  290. align="center"
  291. :min-width="columnWidths.productionStatus.width"
  292. prop="productionStatus"
  293. resizable
  294. />
  295. <el-table-column label="累计" align="center">
  296. <el-table-column
  297. label="注气量(万方)"
  298. align="center"
  299. prop="totalGasInjection"
  300. :formatter="gasInjectionFormatter"
  301. :min-width="columnWidths.totalGasInjection.width"
  302. resizable
  303. />
  304. <el-table-column
  305. label="注水量(方)"
  306. align="center"
  307. prop="totalWaterInjection"
  308. :min-width="columnWidths.totalWaterInjection.width"
  309. resizable
  310. />
  311. <el-table-column
  312. label="完工井次"
  313. align="center"
  314. prop="cumulativeCompletion"
  315. :min-width="columnWidths.cumulativeCompletion.width"
  316. resizable
  317. />
  318. </el-table-column>
  319. <el-table-column
  320. label="产能(万方)"
  321. align="center"
  322. prop="capacity"
  323. :formatter="gasInjectionFormatter"
  324. :min-width="columnWidths.capacity.width"
  325. resizable
  326. />
  327. <el-table-column label="操作" align="center" fixed="right">
  328. <template #default="scope">
  329. <el-button
  330. link
  331. type="primary"
  332. @click="openForm('update', scope.row.id, scope.row)"
  333. v-hasPermi="['pms:iot-rh-daily-report:update']"
  334. >
  335. 编辑
  336. </el-button>
  337. <el-button
  338. link
  339. type="danger"
  340. @click="handleDelete(scope.row.id)"
  341. v-hasPermi="['pms:iot-rh-daily-report:delete']"
  342. >
  343. 删除
  344. </el-button>
  345. </template>
  346. </el-table-column>
  347. </el-table>
  348. </div>
  349. <!-- 分页 -->
  350. <Pagination
  351. :total="total"
  352. v-model:page="queryParams.pageNo"
  353. v-model:limit="queryParams.pageSize"
  354. @pagination="getList"
  355. />
  356. </ContentWrap>
  357. <!-- 表单弹窗:添加/修改 -->
  358. <IotRhDailyReportForm ref="formRef" @success="getList" :row-data="selectedRowData" />
  359. <UnfilledReportDialog
  360. ref="unfilledDialogRef"
  361. :query-params="queryParams"
  362. @close="handleUnfilledDialogClose"
  363. />
  364. </el-col>
  365. </el-row>
  366. </template>
  367. <script setup lang="ts">
  368. import { dateFormatter } from '@/utils/formatTime'
  369. import download from '@/utils/download'
  370. import { IotRhDailyReportApi, IotRhDailyReportVO } from '@/api/pms/iotrhdailyreport'
  371. import IotRhDailyReportForm from './IotRhDailyReportForm.vue'
  372. import UnfilledReportDialog from './UnfilledReportDialog.vue'
  373. import { DICT_TYPE } from '@/utils/dict'
  374. import { ref, reactive, onMounted, onUnmounted } from 'vue'
  375. import DeptTree2 from '@/views/pms/iotrhdailyreport/DeptTree2.vue'
  376. import { useDebounceFn } from '@vueuse/core'
  377. import quarterOfYear from 'dayjs/plugin/quarterOfYear'
  378. import dayjs from 'dayjs'
  379. dayjs.extend(quarterOfYear)
  380. const rangeShortcuts = [
  381. {
  382. text: '今天',
  383. value: () => {
  384. const today = dayjs()
  385. return [today.startOf('day').toDate(), today.endOf('day').toDate()]
  386. }
  387. },
  388. {
  389. text: '昨天',
  390. value: () => {
  391. const yesterday = dayjs().subtract(1, 'day')
  392. return [yesterday.startOf('day').toDate(), yesterday.endOf('day').toDate()]
  393. }
  394. },
  395. {
  396. text: '本周',
  397. value: () => {
  398. return [dayjs().startOf('week').toDate(), dayjs().endOf('week').toDate()]
  399. }
  400. },
  401. {
  402. text: '上周',
  403. value: () => {
  404. const lastWeek = dayjs().subtract(1, 'week')
  405. return [lastWeek.startOf('week').toDate(), lastWeek.endOf('week').toDate()]
  406. }
  407. },
  408. {
  409. text: '本月',
  410. value: () => {
  411. return [dayjs().startOf('month').toDate(), dayjs().endOf('month').toDate()]
  412. }
  413. },
  414. {
  415. text: '上月',
  416. value: () => {
  417. const lastMonth = dayjs().subtract(1, 'month')
  418. return [lastMonth.startOf('month').toDate(), lastMonth.endOf('month').toDate()]
  419. }
  420. },
  421. {
  422. text: '本季度',
  423. value: () => {
  424. return [dayjs().startOf('quarter').toDate(), dayjs().endOf('quarter').toDate()]
  425. }
  426. },
  427. {
  428. text: '上季度',
  429. value: () => {
  430. const lastQuarter = dayjs().subtract(1, 'quarter')
  431. return [lastQuarter.startOf('quarter').toDate(), lastQuarter.endOf('quarter').toDate()]
  432. }
  433. },
  434. {
  435. text: '今年',
  436. value: () => {
  437. return [dayjs().startOf('year').toDate(), dayjs().endOf('year').toDate()]
  438. }
  439. },
  440. {
  441. text: '去年',
  442. value: () => {
  443. const lastYear = dayjs().subtract(1, 'year')
  444. return [lastYear.startOf('year').toDate(), lastYear.endOf('year').toDate()]
  445. }
  446. },
  447. {
  448. text: '最近7天',
  449. value: () => {
  450. return [dayjs().subtract(6, 'day').toDate(), dayjs().toDate()]
  451. }
  452. },
  453. {
  454. text: '最近30天',
  455. value: () => {
  456. return [dayjs().subtract(29, 'day').toDate(), dayjs().toDate()]
  457. }
  458. },
  459. {
  460. text: '最近90天',
  461. value: () => {
  462. return [dayjs().subtract(89, 'day').toDate(), dayjs().toDate()]
  463. }
  464. },
  465. {
  466. text: '最近一年',
  467. value: () => {
  468. return [dayjs().subtract(1, 'year').toDate(), dayjs().toDate()]
  469. }
  470. }
  471. ]
  472. /** 瑞恒日报 列表 */
  473. defineOptions({ name: 'IotRhDailyReport' })
  474. const message = useMessage() // 消息弹窗
  475. const { t } = useI18n() // 国际化
  476. // 添加 selectedRowData 响应式变量
  477. const selectedRowData = ref<Record<string, any> | null>(null)
  478. const loading = ref(true) // 列表的加载中
  479. const list = ref<IotRhDailyReportVO[]>([]) // 列表的数据
  480. const total = ref(0) // 列表的总页数
  481. let queryParams = reactive({
  482. pageNo: 1,
  483. pageSize: 10,
  484. deptId: undefined,
  485. contractName: undefined,
  486. projectId: undefined,
  487. taskName: undefined,
  488. taskId: undefined,
  489. projectClassification: undefined,
  490. relocationDays: undefined,
  491. transitTime: [],
  492. dailyGasInjection: undefined,
  493. dailyWaterInjection: undefined,
  494. dailyPowerUsage: undefined,
  495. dailyInjectGasTime: [],
  496. dailyInjectWaterTime: [],
  497. nonProductionTime: [],
  498. nptReason: undefined,
  499. constructionStartDate: [],
  500. constructionEndDate: [],
  501. productionStatus: undefined,
  502. nextPlan: undefined,
  503. constructionStatus: undefined,
  504. personnel: undefined,
  505. totalGasInjection: undefined,
  506. totalWaterInjection: undefined,
  507. cumulativeCompletion: undefined,
  508. extProperty: undefined,
  509. sort: undefined,
  510. remark: undefined,
  511. status: undefined,
  512. processInstanceId: undefined,
  513. auditStatus: undefined,
  514. createTime: []
  515. })
  516. const queryFormRef = ref() // 搜索的表单
  517. const exportLoading = ref(false) // 导出的加载中
  518. // 添加弹窗引用
  519. const unfilledDialogRef = ref()
  520. const rootDeptId = ref(157)
  521. // 新增统计相关变量
  522. const statistics = ref({
  523. total: '-',
  524. filled: '-',
  525. unFilled: '-',
  526. totalWaterInjection: '-', // 新增累计注水量
  527. totalGasInjection: '-' // 新增累计注气量
  528. })
  529. const totalColor = '#00DD99'
  530. const filledColor = '#0055BB'
  531. const unFilledColor = '#FF5500'
  532. // 表格引用
  533. const tableRef = ref()
  534. // 表格容器引用
  535. const tableContainerRef = ref()
  536. // 工作量统计相关变量
  537. const workloadStatistics = ref({
  538. totalWaterInjection: '-',
  539. totalGasInjection: '-'
  540. })
  541. // 列宽度配置
  542. const columnWidths = ref<
  543. Record<
  544. string,
  545. { label: string; prop: string; width: string; fn?: (row: IotRhDailyReportVO) => string }
  546. >
  547. >({
  548. createTime: {
  549. label: '日期',
  550. prop: 'createTime',
  551. width: '120px',
  552. fn: (row: IotRhDailyReportVO) => dateFormatter(null, null, row.createTime)
  553. },
  554. deptName: {
  555. label: '施工队伍',
  556. prop: 'deptName',
  557. width: '120px'
  558. },
  559. contractName: {
  560. label: '项目',
  561. prop: 'contractName',
  562. width: '120px'
  563. },
  564. taskName: {
  565. label: '任务',
  566. prop: 'taskName',
  567. width: '120px'
  568. },
  569. constructionStatus: {
  570. label: '施工状态',
  571. prop: 'constructionStatus',
  572. width: '120px'
  573. },
  574. relocationDays: {
  575. label: '搬迁安装天数',
  576. prop: 'relocationDays',
  577. width: '120px',
  578. fn: (row: IotRhDailyReportVO) => relocationDaysFormatter(null, null, row.relocationDays, null)
  579. },
  580. designInjection: {
  581. label: '设计注气量(万方)',
  582. prop: 'designInjection',
  583. width: '120px'
  584. },
  585. transitTime: {
  586. label: '运行时效',
  587. prop: 'transitTime',
  588. width: '120px',
  589. fn: (row: IotRhDailyReportVO) => percentageFormatter(null, null, row.transitTime, null)
  590. },
  591. dailyGasInjection: {
  592. label: '注气量(万方)',
  593. prop: 'dailyGasInjection',
  594. width: '120px',
  595. fn: (row: IotRhDailyReportVO) => gasInjectionFormatter(null, null, row.dailyGasInjection, null)
  596. },
  597. dailyWaterInjection: {
  598. label: '注水量(方)',
  599. prop: 'dailyWaterInjection',
  600. width: '120px'
  601. },
  602. dailyInjectGasTime: {
  603. label: '注气时间(H)',
  604. prop: 'dailyInjectGasTime',
  605. width: '120px'
  606. },
  607. dailyInjectWaterTime: {
  608. label: '注水时间(H)',
  609. prop: 'dailyInjectWaterTime',
  610. width: '120px'
  611. },
  612. dailyPowerUsage: {
  613. label: '用电量(kWh)',
  614. prop: 'dailyPowerUsage',
  615. width: '120px'
  616. },
  617. dailyOilUsage: {
  618. label: '油耗(L)',
  619. prop: 'dailyOilUsage',
  620. width: '120px'
  621. },
  622. nonProductionTime: {
  623. label: '非生产时间(H)',
  624. prop: 'nonProductionTime',
  625. width: '120px'
  626. },
  627. nptReason: {
  628. label: '非生产时间原因',
  629. prop: 'nptReason',
  630. width: '120px'
  631. },
  632. constructionStartDate: {
  633. label: '施工开始日期',
  634. prop: 'constructionStartDate',
  635. width: '120px',
  636. fn: (row: IotRhDailyReportVO) => dateFormatter(null, null, row.constructionStartDate)
  637. },
  638. constructionEndDate: {
  639. label: '施工结束日期',
  640. prop: 'constructionEndDate',
  641. width: '120px',
  642. fn: (row: IotRhDailyReportVO) => dateFormatter(null, null, row.constructionEndDate)
  643. },
  644. productionStatus: {
  645. label: '生产动态',
  646. prop: 'productionStatus',
  647. width: '120px'
  648. },
  649. totalGasInjection: {
  650. label: '注气量(万方)',
  651. prop: 'totalGasInjection',
  652. width: '120px',
  653. fn: (row: IotRhDailyReportVO) => gasInjectionFormatter(null, null, row.totalGasInjection, null)
  654. },
  655. totalWaterInjection: {
  656. label: '注水量(方)',
  657. prop: 'totalWaterInjection',
  658. width: '120px'
  659. },
  660. cumulativeCompletion: {
  661. label: '完工井次',
  662. prop: 'cumulativeCompletion',
  663. width: '120px'
  664. },
  665. capacity: {
  666. label: '产能(万方)',
  667. prop: 'capacity',
  668. width: '120px',
  669. fn: (row: IotRhDailyReportVO) => gasInjectionFormatter(null, null, row.capacity, null)
  670. }
  671. })
  672. // 计算文本宽度
  673. const getTextWidth = (text: string, fontSize = 12) => {
  674. const span = document.createElement('span')
  675. span.style.visibility = 'hidden'
  676. span.style.position = 'absolute'
  677. span.style.whiteSpace = 'nowrap'
  678. span.style.fontSize = `${fontSize}px`
  679. span.style.fontFamily = 'PingFang SC'
  680. span.innerText = text
  681. document.body.appendChild(span)
  682. const width = span.offsetWidth
  683. document.body.removeChild(span)
  684. return width
  685. }
  686. const calculateColumnWidths = useDebounceFn(() => {
  687. if (!tableContainerRef.value?.$el) return
  688. Object.values(columnWidths.value).forEach(({ fn, prop, label, width }) => {
  689. width =
  690. Math.min(
  691. ...[
  692. Math.max(
  693. ...[
  694. getTextWidth(label),
  695. ...list.value.map((v) => {
  696. return getTextWidth(fn ? fn(v) : v[prop])
  697. })
  698. ]
  699. ) + (label === '施工状态' || label === '非生产时间原因' ? 30 : 20),
  700. 200
  701. ]
  702. ) + 'px'
  703. columnWidths.value[prop].width = width
  704. })
  705. }, 1000)
  706. // 计算列宽度
  707. // 格式化设计井身结构文本
  708. const formatDesignWellStruct = (text: string | null | undefined) => {
  709. if (!text) return '-'
  710. // 如果文本长度超过30个字符,显示前30个字符并添加省略号
  711. return text.length > 30 ? text.substring(0, 30) + '...' : text
  712. }
  713. // 百分比格式化函数
  714. const percentageFormatter = (row: any, column: any, cellValue: any, index: number | null) => {
  715. if (cellValue === null || cellValue === undefined) return ''
  716. // 将小数转换为百分比,保留两位小数
  717. return `${(parseFloat(cellValue) * 100).toFixed(2)}%`
  718. }
  719. // 添加打开未填报弹窗的方法
  720. const openUnfilledDialog = () => {
  721. // 检查是否选择了创建时间
  722. if (!queryParams.createTime || queryParams.createTime.length === 0) {
  723. message.warning('请先选择创建时间范围')
  724. return
  725. }
  726. // 打开弹窗
  727. unfilledDialogRef.value.open()
  728. }
  729. // 弹窗关闭回调
  730. const handleUnfilledDialogClose = () => {
  731. // 可以在这里处理弹窗关闭后的逻辑
  732. console.log('未填报弹窗已关闭')
  733. }
  734. // 新增获取统计数据的方法
  735. const getStatistics = async () => {
  736. // 重置统计数据
  737. statistics.value = {
  738. total: '-',
  739. filled: '-',
  740. unFilled: '-'
  741. }
  742. // 如果没有选择时间范围,不调用接口
  743. if (!queryParams.createTime || queryParams.createTime.length === 0) {
  744. return
  745. }
  746. try {
  747. const res = await IotRhDailyReportApi.rhDailyReportStatistics({
  748. createTime: queryParams.createTime
  749. })
  750. // 处理统计数据
  751. const statsMap = {}
  752. res.forEach((item) => {
  753. statsMap[item.groupName] = item.count
  754. })
  755. statistics.value = {
  756. total: statsMap['总数'] || '-',
  757. filled: statsMap['已填报'] || '-',
  758. unFilled: statsMap['未填报'] || '-'
  759. }
  760. } catch (error) {
  761. console.error('获取统计数据失败', error)
  762. }
  763. }
  764. /** 查询列表 */
  765. const getList = async () => {
  766. loading.value = true
  767. try {
  768. console.log('22 :>> ', 11)
  769. const data = await IotRhDailyReportApi.getIotRhDailyReportPage(queryParams)
  770. list.value = data.list
  771. total.value = data.total
  772. // 获取统计数据
  773. await getStatistics()
  774. // 获取工作量统计数据
  775. await getWorkloadStatistics()
  776. // 获取数据后计算列宽
  777. nextTick(() => {
  778. calculateColumnWidths()
  779. })
  780. } finally {
  781. loading.value = false
  782. }
  783. }
  784. // 搬迁安装天数格式化函数
  785. const relocationDaysFormatter = (row: any, column: any, cellValue: any, index: number | null) => {
  786. if (cellValue === null || cellValue === undefined || cellValue === '') return ''
  787. const value = parseFloat(cellValue)
  788. // 如果值为负数,显示0,否则显示原值
  789. return value < 0 ? '0' : String(value)
  790. }
  791. // 注气量格式化函数(单位转换:方 -> 万方)
  792. const gasInjectionFormatter = (row: any, column: any, cellValue: any, index: number | null) => {
  793. if (cellValue === null || cellValue === undefined || cellValue === '') return ''
  794. // 将方转换为万方,保留两位小数
  795. const value = parseFloat(cellValue)
  796. return (value / 10000).toFixed(2)
  797. }
  798. // 检查三个时间字段之和是否为24
  799. const checkTimeSumEquals24 = (row: any) => {
  800. // 获取三个字段的值,转换为数字,如果为空则视为0
  801. const gasTime = parseFloat(row.dailyInjectGasTime) || 0
  802. const waterTime = parseFloat(row.dailyInjectWaterTime) || 0
  803. const nonProdTime = parseFloat(row.nonProductionTime) || 0
  804. // 计算总和
  805. const sum = gasTime + waterTime + nonProdTime
  806. // 返回是否等于24(允许一定的浮点数误差)
  807. return Math.abs(sum - 24) < 0.01 // 使用0.01作为误差范围
  808. }
  809. // 单元格样式函数
  810. const cellStyle = ({
  811. row,
  812. column,
  813. rowIndex,
  814. columnIndex
  815. }: {
  816. row: any
  817. column: any
  818. rowIndex: number
  819. columnIndex: number
  820. }) => {
  821. // 只针对 transitTime 列进行处理
  822. if (column.property === 'transitTime') {
  823. // 获取原始值(不是格式化后的百分比值)
  824. const originalValue = row.transitTime
  825. // 检查值是否大于120
  826. if (originalValue !== null && originalValue !== undefined && parseFloat(originalValue) > 1.2) {
  827. return {
  828. color: 'red',
  829. fontWeight: 'bold' // 可选:加粗以更突出显示
  830. }
  831. }
  832. }
  833. // 处理三个时间字段:当日注气时间、当日注水时间、非生产时间
  834. const timeFields = ['dailyInjectGasTime', 'dailyInjectWaterTime', 'nonProductionTime']
  835. if (timeFields.includes(column.property)) {
  836. // 检查三个时间字段之和是否不等于24
  837. if (!checkTimeSumEquals24(row)) {
  838. return {
  839. color: 'orange',
  840. fontWeight: 'bold'
  841. }
  842. }
  843. }
  844. // 默认返回空对象,不应用特殊样式
  845. return {}
  846. }
  847. // 获取工作量统计数据的方法
  848. const getWorkloadStatistics = async () => {
  849. // 重置工作量统计数据
  850. statistics.value.totalWaterInjection = '-'
  851. statistics.value.totalGasInjection = '-'
  852. try {
  853. const res = await IotRhDailyReportApi.totalWorkload(queryParams)
  854. // 处理工作量统计数据
  855. if (res) {
  856. // 累计注水量直接显示,单位:方
  857. statistics.value.totalWaterInjection = res.totalWaterInjection || '-'
  858. // 累计注气量需要转换:方 -> 万方 (除以10000)
  859. if (res.totalGasInjection) {
  860. const gasInjection = parseFloat(res.totalGasInjection)
  861. statistics.value.totalGasInjection = (gasInjection / 10000).toFixed(2)
  862. } else {
  863. statistics.value.totalGasInjection = '-'
  864. }
  865. }
  866. } catch (error) {
  867. console.error('获取工作量统计数据失败', error)
  868. }
  869. }
  870. /** 搜索按钮操作 */
  871. const handleQuery = () => {
  872. queryParams.pageNo = 1
  873. getList()
  874. }
  875. const route = useRoute()
  876. /** 重置按钮操作 */
  877. const resetQuery = () => {
  878. queryFormRef.value.resetFields()
  879. // 重置后需要重新获取统计数据
  880. getStatistics()
  881. // 重新获取工作量统计数据
  882. getWorkloadStatistics()
  883. handleQuery()
  884. }
  885. /** 添加/修改操作 */
  886. const formRef = ref()
  887. const openForm = (type: string, id?: number, row?: any) => {
  888. // 保存当前行数据
  889. if (row) {
  890. selectedRowData.value = {
  891. deptName: row.deptName,
  892. contractName: row.contractName,
  893. taskName: row.taskName,
  894. relocationDays: row.relocationDays
  895. }
  896. } else {
  897. selectedRowData.value = null
  898. }
  899. formRef.value.open(type, id)
  900. }
  901. /** 删除按钮操作 */
  902. const handleDelete = async (id: number) => {
  903. try {
  904. // 删除的二次确认
  905. await message.delConfirm()
  906. // 发起删除
  907. await IotRhDailyReportApi.deleteIotRhDailyReport(id)
  908. message.success(t('common.delSuccess'))
  909. // 刷新列表
  910. await getList()
  911. } catch {}
  912. }
  913. // 响应式变量存储选中的部门
  914. const selectedDept = ref<{ id: number; name: string }>()
  915. /** 处理部门被点击 */
  916. const handleDeptNodeClick = async (row) => {
  917. // 记录选中的部门信息
  918. selectedDept.value = { id: row.id, name: row.name }
  919. queryParams.deptId = row.id
  920. await getList()
  921. }
  922. /** 导出按钮操作 */
  923. const handleExport = async () => {
  924. try {
  925. // 导出的二次确认
  926. await message.exportConfirm()
  927. // 发起导出
  928. exportLoading.value = true
  929. const data = await IotRhDailyReportApi.exportIotRhDailyReport(queryParams)
  930. download.excel(data, '瑞恒日报.xls')
  931. } catch {
  932. } finally {
  933. exportLoading.value = false
  934. }
  935. }
  936. // 声明 ResizeObserver 实例
  937. let resizeObserver: ResizeObserver | null = null
  938. /** 初始化 **/
  939. onMounted(() => {
  940. if (Object.keys(route.query).length > 0) {
  941. queryParams = {
  942. ...queryParams,
  943. ...route.query,
  944. deptId: Number(route.query.deptId) as any
  945. }
  946. handleQuery()
  947. } else getList()
  948. // 创建 ResizeObserver 监听表格容器尺寸变化
  949. if (tableContainerRef.value?.$el) {
  950. resizeObserver = new ResizeObserver(() => {
  951. // 使用防抖避免频繁触发
  952. clearTimeout((window as any).resizeTimer)
  953. ;(window as any).resizeTimer = setTimeout(() => {
  954. calculateColumnWidths()
  955. }, 100)
  956. })
  957. resizeObserver.observe(tableContainerRef.value.$el)
  958. }
  959. })
  960. onUnmounted(() => {
  961. // 清除 ResizeObserver
  962. if (resizeObserver && tableContainerRef.value?.$el) {
  963. resizeObserver.unobserve(tableContainerRef.value.$el)
  964. resizeObserver = null
  965. }
  966. // 清除定时器
  967. if ((window as any).resizeTimer) {
  968. clearTimeout((window as any).resizeTimer)
  969. }
  970. })
  971. // 监听列表数据变化重新计算列宽
  972. watch(
  973. list,
  974. () => {
  975. nextTick(() => calculateColumnWidths())
  976. },
  977. { deep: true }
  978. )
  979. </script>
  980. <style scoped>
  981. /* 表格容器样式,确保水平滚动 */
  982. .table-container {
  983. width: 100%;
  984. overflow-x: auto;
  985. }
  986. /* 确保表格单元格内容不换行 */
  987. /* :deep(.el-table .cell) {
  988. white-space: nowrap;
  989. } */
  990. /* 确保表格列标题不换行 */
  991. /* :deep(.el-table th > .cell) {
  992. white-space: nowrap;
  993. } */
  994. /* 调整表格最小宽度,确保内容完全显示 */
  995. :deep(.el-table) {
  996. min-width: 100%;
  997. }
  998. /* 强制显示所有内容,防止省略号 */
  999. /* :deep(.el-table td.el-table__cell),
  1000. :deep(.el-table th.el-table__cell) {
  1001. overflow: visible !important;
  1002. } */
  1003. /* :deep(.el-table .cell) {
  1004. overflow: visible !important;
  1005. text-overflow: clip !important;
  1006. } */
  1007. /* :deep(.contract-name-column .cell) {
  1008. overflow: hidden !important;
  1009. text-overflow: ellipsis !important;
  1010. white-space: nowrap !important;
  1011. } */
  1012. /* 颜色说明区域样式 */
  1013. .color-legend {
  1014. display: flex;
  1015. padding: 12px 16px;
  1016. background-color: #f8f9fa;
  1017. border-left: 4px solid #e6f7ff;
  1018. border-radius: 4px;
  1019. flex-direction: column;
  1020. gap: 8px;
  1021. }
  1022. .legend-item {
  1023. display: flex;
  1024. align-items: center;
  1025. gap: 8px;
  1026. font-size: 14px;
  1027. }
  1028. .color-indicator {
  1029. display: inline-block;
  1030. width: 12px;
  1031. height: 12px;
  1032. border-radius: 50%;
  1033. }
  1034. .color-indicator.red {
  1035. background-color: red;
  1036. }
  1037. .color-indicator.orange {
  1038. background-color: orange;
  1039. }
  1040. /* 统计区域未填报链接样式 */
  1041. .unfilled-link {
  1042. color: #f50;
  1043. text-decoration: underline;
  1044. cursor: pointer;
  1045. }
  1046. .unfilled-link:hover {
  1047. color: #f73;
  1048. }
  1049. .unfilled-link.disabled {
  1050. color: #ccc;
  1051. text-decoration: none;
  1052. cursor: not-allowed;
  1053. }
  1054. </style>
  1055. <style>
  1056. /* 设计井身结构 tooltip 样式 - 保留换行符 */
  1057. .design-well-struct-tooltip {
  1058. max-width: 500px;
  1059. line-height: 1.5;
  1060. white-space: pre-line;
  1061. }
  1062. /* 统计区域样式 */
  1063. .statistics-container {
  1064. display: flex;
  1065. justify-content: space-around;
  1066. padding: 10px 0;
  1067. }
  1068. .stat-item {
  1069. min-width: 0; /* 防止内容溢出 */
  1070. font-size: 16px;
  1071. font-weight: 500;
  1072. text-align: center;
  1073. flex: 1;
  1074. }
  1075. /* 确保统计项内容不换行 */
  1076. .stat-item span {
  1077. white-space: nowrap;
  1078. }
  1079. </style>