rh-table.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <script setup lang="ts">
  2. import { useTableComponents } from '@/components/ZmTable/useTableComponents'
  3. import { DICT_TYPE, realValue } from '@/utils/dict'
  4. import dayjs from 'dayjs'
  5. import { TableColumnCtx } from 'element-plus'
  6. const { t } = useI18n()
  7. interface ListItem {
  8. createTime: string
  9. deptName: string
  10. taskName: string
  11. constructionStatus: string
  12. relocationDays: number
  13. designInjection: number
  14. dailyGasInjection: number
  15. dailyWaterInjection: number
  16. dailyInjectGasTime: number
  17. dailyInjectWaterTime: number
  18. dailyPowerUsage: number
  19. dailyOilUsage: number
  20. gasElectricityRatio: number
  21. nonProductionRate: number
  22. accidentTime: number
  23. repairTime: number
  24. selfStopTime: number
  25. complexityTime: number
  26. relocationTime: number
  27. rectificationTime: number
  28. waitingStopTime: number
  29. winterBreakTime: number
  30. partyaDesign: number
  31. partyaPrepare: number
  32. partyaResource: number
  33. otherNptTime: number
  34. otherNptReason: string
  35. productionStatus: string
  36. contractName: string
  37. wellTotalGasInjection: number
  38. wellTotalWaterInjection: number
  39. wellTotalPower: number
  40. wellTotalFuel: number
  41. yearTotalGasInjection: number
  42. yearTotalWaterInjection: number
  43. yearTotalPower: number
  44. yearTotalFuel: number
  45. capacity: number
  46. techniqueNames: string
  47. }
  48. const props = defineProps({
  49. list: {
  50. type: Array as PropType<ListItem[]>,
  51. default: () => []
  52. },
  53. loading: {
  54. type: Boolean,
  55. default: false
  56. },
  57. total: {
  58. type: Number,
  59. default: 0
  60. },
  61. pageNo: {
  62. type: Number,
  63. default: 0
  64. },
  65. pageSize: {
  66. type: Number,
  67. default: 0
  68. },
  69. showAction: {
  70. type: Boolean,
  71. default: true
  72. },
  73. isIndex: {
  74. type: Boolean,
  75. default: false
  76. }
  77. })
  78. const emits = defineEmits(['update:pageNo', 'update:pageSize', 'sizeChange', 'currentChange'])
  79. const { list, loading, total, pageNo, pageSize, showAction, isIndex } = toRefs(props)
  80. const { ZmTable, ZmTableColumn } = useTableComponents<ListItem>()
  81. function percentageFormatter(row: ListItem) {
  82. const capacity = Number(row?.capacity)
  83. const dailyGasInjection = Number(row?.dailyGasInjection)
  84. if (!capacity || !dailyGasInjection) {
  85. return '0.00%'
  86. }
  87. return ((dailyGasInjection / capacity) * 100).toFixed(2) + '%'
  88. }
  89. function unitformatter(
  90. _row: ListItem,
  91. _column: TableColumnCtx<ListItem>,
  92. cellValue: any,
  93. _index: number
  94. ) {
  95. if (cellValue === null || cellValue === undefined || cellValue == '') return ''
  96. const value = parseFloat(cellValue)
  97. return (value / 10000).toFixed(4)
  98. }
  99. const cellStyle = ({ row, column }: { row: any; column: any }) => {
  100. if (column.property === 'transitTime') {
  101. const capacity = Number(row?.capacity)
  102. const dailyGasInjection = Number(row?.dailyGasInjection)
  103. if (capacity && dailyGasInjection) {
  104. const ratio = dailyGasInjection / capacity
  105. if (ratio > 1.2) {
  106. return {
  107. color: 'red',
  108. fontWeight: 'bold',
  109. backgroundColor: 'var(--el-color-danger-light-9)'
  110. }
  111. }
  112. }
  113. }
  114. return {}
  115. }
  116. function handleSizeChange(val: number) {
  117. emits('sizeChange', val)
  118. }
  119. function handleCurrentChange(val: number) {
  120. emits('currentChange', val)
  121. }
  122. </script>
  123. <template>
  124. <div class="bg-white dark:bg-[#1d1e1f] shadow rounded-lg flex flex-col p-4">
  125. <div class="flex-1 relative">
  126. <el-auto-resizer class="absolute">
  127. <template #default="{ width, height }">
  128. <zm-table
  129. :data="list"
  130. :loading="loading"
  131. :width="width"
  132. :max-height="height"
  133. :height="height"
  134. show-border
  135. :cell-style="cellStyle"
  136. >
  137. <zm-table-column
  138. v-if="isIndex"
  139. type="index"
  140. :label="t('monitor.serial')"
  141. :width="60"
  142. fixed="left"
  143. />
  144. <zm-table-column
  145. label="日期"
  146. prop="createTime"
  147. fixed="left"
  148. cover-formatter
  149. :real-value="(row: ListItem) => dayjs(row.createTime).format('YYYY-MM-DD')"
  150. />
  151. <zm-table-column label="施工队伍" prop="deptName" fixed="left" />
  152. <zm-table-column label="任务" prop="taskName" fixed="left" />
  153. <zm-table-column
  154. prop="constructionStatus"
  155. fixed="left"
  156. :label="t('project.status')"
  157. :real-value="
  158. (row: ListItem) =>
  159. realValue(DICT_TYPE.PMS_PROJECT_TASK_SCHEDULE, row.constructionStatus ?? '')
  160. "
  161. >
  162. <template #default="scope">
  163. <dict-tag
  164. :type="DICT_TYPE.PMS_PROJECT_TASK_SCHEDULE"
  165. :value="scope.row.constructionStatus ?? ''"
  166. />
  167. </template>
  168. </zm-table-column>
  169. <zm-table-column prop="auditStatus" label="审批状态" v-if="!isIndex">
  170. <template #default="scope">
  171. <el-tag v-if="scope.row.auditStatus === 0" type="info">
  172. {{ '待提交' }}
  173. </el-tag>
  174. <el-tag v-else-if="scope.row.auditStatus === 10">
  175. {{ '待审批' }}
  176. </el-tag>
  177. <el-tag v-else-if="scope.row.auditStatus === 20" type="success">
  178. {{ '审批通过' }}
  179. </el-tag>
  180. <el-tag v-else-if="scope.row.auditStatus === 30" type="danger">
  181. {{ '审批拒绝' }}
  182. </el-tag>
  183. </template>
  184. </zm-table-column>
  185. <zm-table-column label="施工区域" prop="location" />
  186. <zm-table-column label="施工工艺" prop="techniqueNames" />
  187. <zm-table-column label="搬迁安装天数" prop="relocationDays" />
  188. <zm-table-column label="设计注气量(万方)" prop="designInjection" />
  189. <zm-table-column
  190. label="运行时效"
  191. prop="transitTime"
  192. cover-formatter
  193. :real-value="percentageFormatter"
  194. />
  195. <zm-table-column label="当日">
  196. <zm-table-column
  197. label="注气量(万方)"
  198. prop="dailyGasInjection"
  199. cover-formatter
  200. :real-value="unitformatter"
  201. />
  202. <zm-table-column label="注水量(方)" prop="dailyWaterInjection" />
  203. <zm-table-column label="注气时间(H)" prop="dailyInjectGasTime" />
  204. <zm-table-column label="注水时间(H)" prop="dailyInjectWaterTime" />
  205. <zm-table-column label="用电量(kWh)" prop="dailyPowerUsage" />
  206. <zm-table-column label="油耗(L)" prop="dailyOilUsage" />
  207. <zm-table-column label="气电比" prop="gasElectricityRatio" />
  208. </zm-table-column>
  209. <zm-table-column
  210. prop="nonProductionRate"
  211. label="非生产时效"
  212. cover-formatter
  213. :real-value="(row) => (Number(row.nonProductionRate ?? 0) * 100).toFixed(2) + '%'"
  214. />
  215. <zm-table-column label="非生产时间">
  216. <zm-table-column prop="accidentTime" label="工程质量" />
  217. <zm-table-column prop="repairTime" label="设备故障" />
  218. <zm-table-column prop="selfStopTime" label="设备保养" />
  219. <zm-table-column prop="complexityTime" label="技术受限" />
  220. <zm-table-column prop="relocationTime" label="生产配合" />
  221. <zm-table-column prop="rectificationTime" label="生产组织" />
  222. <zm-table-column prop="waitingStopTime" label="不可抗力" />
  223. <zm-table-column prop="winterBreakTime" label="待命" />
  224. <zm-table-column prop="partyaDesign" label="甲方设计" />
  225. <zm-table-column prop="partyaPrepare" label="甲方准备" />
  226. <zm-table-column prop="partyaResource" label="甲方资源" />
  227. <zm-table-column prop="otherNptTime" label="其它非生产时间" />
  228. </zm-table-column>
  229. <zm-table-column prop="otherNptReason" label="其他非生产时间原因" />
  230. <zm-table-column prop="productionStatus" label="生产动态" />
  231. <zm-table-column prop="contractName" label="项目" />
  232. <zm-table-column label="井累计" v-if="isIndex">
  233. <zm-table-column prop="wellTotalGasInjection" label="注气量(万方)" />
  234. <zm-table-column prop="wellTotalWaterInjection" label="注水量(方)" />
  235. <zm-table-column prop="wellTotalPower" label="用电量(MWh)" />
  236. <zm-table-column prop="wellTotalFuel" label="油耗(L)" />
  237. </zm-table-column>
  238. <zm-table-column label="年累计" v-if="isIndex">
  239. <zm-table-column prop="yearTotalGasInjection" label="注气量(万方)" />
  240. <zm-table-column prop="yearTotalWaterInjection" label="注水量(方)" />
  241. <zm-table-column prop="yearTotalPower" label="用电量(MWh)" />
  242. <zm-table-column prop="yearTotalFuel" label="油耗(L)" />
  243. </zm-table-column>
  244. <zm-table-column label="累计" v-if="!isIndex">
  245. <zm-table-column prop="totalGasInjection" label="注气量(万方)" />
  246. <zm-table-column prop="totalWaterInjection" label="注水量(方)" />
  247. <zm-table-column prop="cumulativeCompletion" label="完工井次" />
  248. </zm-table-column>
  249. <zm-table-column
  250. prop="capacity"
  251. label="产能(万方)"
  252. cover-formatter
  253. :real-value="unitformatter"
  254. />
  255. <zm-table-column label="操作" :width="120" fixed="right" v-if="showAction">
  256. <template #default="scope">
  257. <slot name="action" :row="scope.row"></slot>
  258. </template>
  259. </zm-table-column>
  260. </zm-table>
  261. </template>
  262. </el-auto-resizer>
  263. </div>
  264. <div class="h-8 mt-2 flex items-center justify-end">
  265. <el-pagination
  266. size="default"
  267. v-show="total > 0"
  268. :current-page="pageNo"
  269. :page-size="pageSize"
  270. :background="true"
  271. :page-sizes="[10, 20, 30, 50, 100]"
  272. :total="total"
  273. layout="total, sizes, prev, pager, next, jumper"
  274. @size-change="handleSizeChange"
  275. @current-change="handleCurrentChange"
  276. />
  277. </div>
  278. </div>
  279. </template>
  280. <style scoped></style>