summary.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. <script setup lang="ts">
  2. import dayjs from 'dayjs'
  3. import { IotRyDailyReportApi } from '@/api/pms/iotrydailyreport'
  4. import { useDebounceFn } from '@vueuse/core'
  5. import CountTo from '@/components/count-to1.vue'
  6. import * as echarts from 'echarts'
  7. import UnfilledReportDialog from './UnfilledReportDialog.vue'
  8. import { Motion, AnimatePresence } from 'motion-v'
  9. import { rangeShortcuts } from '@/utils/formatTime'
  10. import download from '@/utils/download'
  11. import { useUserStore } from '@/store/modules/user'
  12. const deptId = useUserStore().getUser.deptId
  13. interface Query {
  14. pageNo: number
  15. pageSize: number
  16. deptId: number
  17. contractName?: string
  18. taskName?: string
  19. createTime: string[]
  20. projectClassification: 1 | 2
  21. }
  22. const id = deptId
  23. const query = ref<Query>({
  24. pageNo: 1,
  25. pageSize: 10,
  26. deptId: deptId,
  27. createTime: [
  28. ...rangeShortcuts[1].value().map((item) => dayjs(item).format('YYYY-MM-DD HH:mm:ss'))
  29. ],
  30. projectClassification: 1
  31. })
  32. const totalWorkKeys: [string, string, string, string, number][] = [
  33. ['totalFootage', 'M', '累计进尺', 'i-solar:ruler-bold text-sky', 2],
  34. [
  35. 'utilizationRate',
  36. '%',
  37. '设备利用率',
  38. 'i-material-symbols:check-circle-outline-rounded text-emerald',
  39. 0
  40. ],
  41. [
  42. 'totalPowerConsumption',
  43. 'MWh',
  44. '累计用电量',
  45. 'i-material-symbols:electric-bolt-outline-rounded text-sky',
  46. 2
  47. ],
  48. [
  49. 'totalFuelConsumption',
  50. '升',
  51. '累计油耗',
  52. 'i-material-symbols:directions-car-outline-rounded text-sky',
  53. 2
  54. ],
  55. [
  56. 'averageFuelConsumption',
  57. '升',
  58. '平均油耗',
  59. 'i-material-symbols:directions-car-outline-rounded text-sky',
  60. 2
  61. ],
  62. ['totalCount', '个', '总数', 'i-tabler:report-analytics text-sky', 0],
  63. [
  64. 'alreadyReported',
  65. '个',
  66. '已填报',
  67. 'i-material-symbols:check-circle-outline-rounded text-emerald',
  68. 0
  69. ],
  70. ['notReported', '个', '未填报', 'i-material-symbols:cancel-outline-rounded text-rose', 0]
  71. ]
  72. const totalWork = ref({
  73. totalCount: 0,
  74. alreadyReported: 0,
  75. notReported: 0,
  76. totalFuelConsumption: 0,
  77. totalPowerConsumption: 0,
  78. totalFootage: 0,
  79. averageFuelConsumption: 0,
  80. utilizationRate: 0
  81. })
  82. const totalLoading = ref(false)
  83. const getTotal = useDebounceFn(async () => {
  84. totalLoading.value = true
  85. const { pageNo, pageSize, ...other } = query.value
  86. try {
  87. let res1: any[]
  88. if (query.value.createTime && query.value.createTime.length === 2) {
  89. res1 = await IotRyDailyReportApi.ryDailyReportStatistics({
  90. createTime: query.value.createTime,
  91. projectClassification: query.value.projectClassification
  92. })
  93. totalWork.value.totalCount = res1[0].count
  94. totalWork.value.alreadyReported = res1[1].count
  95. totalWork.value.notReported = res1[2].count
  96. }
  97. const res2 = await IotRyDailyReportApi.totalWorkload(other)
  98. totalWork.value = {
  99. ...totalWork.value,
  100. totalFootage: 0,
  101. ...res2,
  102. totalPowerConsumption: (res2.totalPowerConsumption || 0) / 1000,
  103. totalGasInjection: (res2.totalGasInjection || 0) / 10000,
  104. totalFuelConsumption: res2.totalFuelConsumption || 0,
  105. averageFuelConsumption: res2.averageFuelConsumption || 0,
  106. utilizationRate: Number(((res2.utilizationRate || 0) * 100).toFixed(2))
  107. }
  108. } finally {
  109. totalLoading.value = false
  110. }
  111. }, 1000)
  112. interface List {
  113. id: number | null
  114. name: string | null
  115. type: '1' | '2' | '3'
  116. cumulativeGasInjection: number | null
  117. cumulativeWaterInjection: number | null
  118. cumulativePowerConsumption: number | null
  119. cumulativeFuelConsumption: number | null
  120. transitTime: number | null
  121. nonProductiveTime: number | null
  122. averageFuelConsumption: number | null
  123. utilizationRate: number | null
  124. }
  125. const list = ref<List[]>([])
  126. const type = ref('2')
  127. const columns = (type: string) => {
  128. return [
  129. {
  130. label: type === '2' ? '项目部' : '队伍',
  131. prop: 'name'
  132. },
  133. {
  134. label: '累计进尺(M)',
  135. prop: 'cumulativeFootage'
  136. },
  137. {
  138. label: '累计用电量(MWh)',
  139. prop: 'cumulativePowerConsumption'
  140. },
  141. {
  142. label: '累计油耗(升)',
  143. prop: 'cumulativeFuelConsumption'
  144. },
  145. {
  146. label: '平均油耗(升)',
  147. prop: 'averageFuelConsumption'
  148. },
  149. {
  150. label: '平均时效(%)',
  151. prop: 'transitTime'
  152. },
  153. {
  154. label: '非生产时效(%)',
  155. prop: 'nonProductiveTime'
  156. },
  157. {
  158. label: '设备利用率(%)',
  159. prop: 'utilizationRate'
  160. }
  161. ]
  162. }
  163. const listLoading = ref(false)
  164. const formatter = (row: List, column: any) => {
  165. if (column.property === 'transitTime') {
  166. return (Number(row.transitTime ?? 0) * 100).toFixed(2) + '%'
  167. } else if (column.property === 'nonProductiveTime') {
  168. return (Number(row.nonProductiveTime ?? 0) * 100).toFixed(2) + '%'
  169. } else if (column.property === 'utilizationRate') {
  170. return (Number(row.utilizationRate ?? 0) * 100).toFixed(2) + '%'
  171. } else return row[column.property] ?? 0
  172. }
  173. const getList = useDebounceFn(async () => {
  174. listLoading.value = true
  175. try {
  176. const res = await IotRyDailyReportApi.getIotRyDailyReportSummary(query.value)
  177. const { list: reslist } = res
  178. type.value = reslist[0]?.type || '2'
  179. list.value = reslist.map(
  180. ({ id, projectDeptId, projectDeptName, teamId, teamName, sort, taskId, type, ...other }) => ({
  181. id: type === '2' ? projectDeptId : teamId,
  182. name: type === '2' ? projectDeptName : teamName,
  183. ...other,
  184. cumulativePowerConsumption: ((other.cumulativePowerConsumption || 0) / 1000).toFixed(2),
  185. cumulativeFuelConsumption: (other.cumulativeFuelConsumption || 0).toFixed(2),
  186. averageFuelConsumption: (other.averageFuelConsumption || 0).toFixed(2),
  187. utilizationRate: other.utilizationRate || 0
  188. })
  189. )
  190. } finally {
  191. listLoading.value = false
  192. }
  193. }, 1000)
  194. const tab = ref<'表格' | '看板'>('表格')
  195. const currentTab = ref<'表格' | '看板'>('表格')
  196. const deptName = ref('瑞鹰国际钻井')
  197. const direction = ref<'left' | 'right'>('right')
  198. const handleSelectTab = (val: '表格' | '看板') => {
  199. tab.value = val
  200. direction.value = val === '看板' ? 'right' : 'left'
  201. nextTick(() => {
  202. currentTab.value = val
  203. setTimeout(() => {
  204. render()
  205. })
  206. })
  207. }
  208. const chartRef = ref<HTMLDivElement | null>(null)
  209. let chart: echarts.ECharts | null = null
  210. let chartContainerEl: HTMLDivElement | null = null
  211. const xAxisData = ref<string[]>([])
  212. const legend = ref<string[][]>([
  213. // ['累计油耗 (万升)', 'cumulativeFuelConsumption'],
  214. ['油耗 (升)', 'cumulativeFuelConsumption'],
  215. ['进尺 (M)', 'cumulativeFootage'],
  216. ['用电量 (KWh)', 'cumulativePowerConsumption'],
  217. // ['累计用电量 (MWh)', 'cumulativePowerConsumption'],
  218. ['平均时效 (%)', 'transitTime'],
  219. ['设备利用率 (%)', 'utilizationRate']
  220. ])
  221. const chartData = ref<Record<string, number[]>>({
  222. cumulativeFuelConsumption: [],
  223. cumulativeFootage: [],
  224. cumulativePowerConsumption: [],
  225. transitTime: [],
  226. utilizationRate: []
  227. })
  228. let chartLoading = ref(false)
  229. const getChart = useDebounceFn(async () => {
  230. chartLoading.value = true
  231. try {
  232. // 创建查询参数,如果 createTime 为空则不传
  233. const params: any = {
  234. deptId: query.value.deptId,
  235. projectClassification: query.value.projectClassification
  236. }
  237. // 只有 createTime 有值时才添加
  238. if (query.value.createTime && query.value.createTime.length === 2) {
  239. params.createTime = query.value.createTime
  240. }
  241. const res = await IotRyDailyReportApi.getIotRyDailyReportSummaryPolyline(query.value)
  242. chartData.value = {
  243. cumulativeFuelConsumption: res.map((item) => item.cumulativeFuelConsumption || 0),
  244. // cumulativeFuelConsumption: res.map((item) => (item.cumulativeFuelConsumption || 0) / 10000),
  245. cumulativeFootage: res.map((item) => item.cumulativeFootage || 0),
  246. cumulativePowerConsumption: res.map((item) => item.cumulativePowerConsumption || 0),
  247. // cumulativePowerConsumption: res.map((item) => (item.cumulativePowerConsumption || 0) / 1000),
  248. transitTime: res.map((item) => (item.transitTime || 0) * 100),
  249. utilizationRate: res.map((item) => Number(((item.utilizationRate || 0) * 100).toFixed(2)))
  250. }
  251. xAxisData.value = res.map((item) => item.reportDate || '')
  252. } finally {
  253. chartLoading.value = false
  254. }
  255. }, 1000)
  256. const resizer = () => {
  257. chart?.resize()
  258. }
  259. onUnmounted(() => {
  260. window.removeEventListener('resize', resizer)
  261. chart?.dispose()
  262. chart = null
  263. chartContainerEl = null
  264. })
  265. const selectedLegends = ref<Record<string, boolean>>({})
  266. const intervalArr = ref<number[]>([])
  267. const maxInterval = ref(0)
  268. const minInterval = ref(0)
  269. const calcIntervals = () => {
  270. let maxVal = -Infinity
  271. let minVal = Infinity
  272. let hasData = false
  273. for (const [name, key] of legend.value) {
  274. if (selectedLegends.value[name] !== false) {
  275. const dataset = chartData.value[key] || []
  276. if (dataset.length > 0) {
  277. hasData = true
  278. for (const val of dataset) {
  279. if (val > maxVal) maxVal = val
  280. if (val < minVal) minVal = val
  281. }
  282. }
  283. }
  284. }
  285. if (!hasData) {
  286. maxVal = 10000
  287. minVal = 0
  288. } else {
  289. minVal = minVal > 0 ? 0 : minVal
  290. }
  291. const maxDigits = (Math.floor(maxVal) + '').length
  292. const minDigits = minVal === 0 ? 0 : (Math.floor(Math.abs(minVal)) + '').length
  293. const interval = Math.max(maxDigits, minDigits)
  294. maxInterval.value = interval
  295. minInterval.value = minDigits
  296. const arr = [0]
  297. for (let i = 1; i <= interval; i++) {
  298. arr.push(Math.pow(10, i))
  299. }
  300. intervalArr.value = arr
  301. }
  302. const mapDataValue = (value: number) => {
  303. if (value === 0) return 0
  304. const isPositive = value > 0
  305. const absItem = Math.abs(value)
  306. if (!intervalArr.value.length) return value
  307. const min_value = Math.max(...intervalArr.value.filter((v) => v <= absItem))
  308. const min_index = intervalArr.value.findIndex((v) => v === min_value)
  309. const denominator =
  310. min_index < intervalArr.value.length - 1
  311. ? intervalArr.value[min_index + 1] - intervalArr.value[min_index]
  312. : intervalArr.value[min_index] || 1
  313. const new_value = (absItem - min_value) / denominator + min_index
  314. return isPositive ? new_value : -new_value
  315. }
  316. const getSeries = () => {
  317. return legend.value.map(([name, key]) => ({
  318. name,
  319. type: 'line',
  320. smooth: true,
  321. showSymbol: true,
  322. data: chartData.value[key].map((value) => mapDataValue(value))
  323. }))
  324. }
  325. const initChart = () => {
  326. if (!chartRef.value) return
  327. if (chart && chartContainerEl === chartRef.value) {
  328. return
  329. }
  330. chart?.dispose()
  331. chart = echarts.init(chartRef.value, undefined, { renderer: 'canvas' })
  332. chartContainerEl = chartRef.value
  333. window.addEventListener('resize', resizer)
  334. chart.on('legendselectchanged', (params: any) => {
  335. selectedLegends.value = params.selected
  336. calcIntervals()
  337. chart?.setOption({
  338. yAxis: {
  339. min: -minInterval.value,
  340. max: maxInterval.value
  341. },
  342. series: getSeries()
  343. })
  344. })
  345. }
  346. const render = () => {
  347. if (!chartRef.value) return
  348. initChart()
  349. legend.value.forEach(([name]) => {
  350. selectedLegends.value[name] = true
  351. })
  352. calcIntervals()
  353. chart?.setOption(
  354. {
  355. tooltip: {
  356. trigger: 'axis',
  357. axisPointer: { type: 'line' },
  358. formatter: (params: any) => {
  359. let d = `${params[0].axisValueLabel}<br>`
  360. let item = params.map((el: any) => {
  361. const realValue = chartData.value[legend.value[el.componentIndex][1]][el.dataIndex]
  362. return `<div class="flex items-center justify-between mt-1 gap-1">
  363. <span>${el.marker} ${el.seriesName}</span>
  364. <span>${realValue.toFixed(2)} ${el.seriesName.split(' ')[1] || ''}</span>
  365. </div>`
  366. })
  367. return d + item.join('')
  368. }
  369. },
  370. legend: {
  371. data: legend.value.map(([name]) => name),
  372. selected: selectedLegends.value,
  373. show: true
  374. },
  375. xAxis: {
  376. type: 'category',
  377. data: xAxisData.value
  378. },
  379. yAxis: {
  380. type: 'value',
  381. min: -minInterval.value,
  382. max: maxInterval.value,
  383. interval: 1,
  384. axisLabel: {
  385. formatter: (v: number) => {
  386. const num = v === 0 ? 0 : v > 0 ? Math.pow(10, v) : -Math.pow(10, -v)
  387. return num.toLocaleString()
  388. }
  389. }
  390. },
  391. series: getSeries()
  392. },
  393. true
  394. )
  395. }
  396. const handleDeptNodeClick = (node: any) => {
  397. deptName.value = node.name
  398. handleQuery()
  399. }
  400. const handleQuery = (setPage = true) => {
  401. if (setPage) {
  402. query.value.pageNo = 1
  403. }
  404. getChart().then(() => {
  405. render()
  406. })
  407. getList()
  408. getTotal()
  409. }
  410. const resetQuery = () => {
  411. query.value = {
  412. pageNo: 1,
  413. pageSize: 10,
  414. deptId: deptId,
  415. createTime: [
  416. ...rangeShortcuts[1].value().map((item) => dayjs(item).format('YYYY-MM-DD HH:mm:ss'))
  417. ],
  418. projectClassification: 1
  419. }
  420. handleQuery()
  421. }
  422. watch(
  423. () => query.value.createTime,
  424. (val) => {
  425. if (!val) {
  426. totalWork.value.totalCount = 0
  427. totalWork.value.notReported = 0
  428. totalWork.value.alreadyReported = 0
  429. }
  430. handleQuery(false)
  431. }
  432. )
  433. onMounted(() => {
  434. handleQuery()
  435. })
  436. const exportChart = () => {
  437. if (!chart) return
  438. let img = new Image()
  439. img.src = chart.getDataURL({
  440. type: 'png',
  441. pixelRatio: 1,
  442. backgroundColor: '#fff'
  443. })
  444. img.onload = function () {
  445. let canvas = document.createElement('canvas')
  446. canvas.width = img.width
  447. canvas.height = img.height
  448. let ctx = canvas.getContext('2d')
  449. ctx?.drawImage(img, 0, 0)
  450. let dataURL = canvas.toDataURL('image/png')
  451. let a = document.createElement('a')
  452. let event = new MouseEvent('click')
  453. a.href = dataURL
  454. a.download = `瑞鹰钻井日报统计数据.png`
  455. a.dispatchEvent(event)
  456. }
  457. }
  458. const exportData = async () => {
  459. const res = await IotRyDailyReportApi.exportRyDailyReportStatistics(query.value)
  460. download.excel(res, '瑞鹰钻井日报统计数据.xlsx')
  461. }
  462. const exportAll = async () => {
  463. if (tab.value === '看板') exportChart()
  464. else exportData()
  465. }
  466. const message = useMessage()
  467. const unfilledDialogRef = ref()
  468. const openUnfilledDialog = () => {
  469. // 检查是否选择了创建时间
  470. if (!query.value.createTime || query.value.createTime.length === 0) {
  471. message.warning('请先选择创建时间范围')
  472. return
  473. }
  474. // 打开弹窗
  475. unfilledDialogRef.value?.open()
  476. }
  477. const router = useRouter()
  478. const tolist = (id: number, non: boolean = false) => {
  479. const { pageNo, pageSize, ...rest } = query.value
  480. router.push({
  481. path: '/iotdayilyreport/IotRyDailyReport',
  482. query: {
  483. ...rest,
  484. deptId: id,
  485. ...(non ? { nonProductFlag: 'Y' } : {})
  486. }
  487. })
  488. }
  489. </script>
  490. <template>
  491. <div
  492. class="grid grid-cols-[auto_1fr] grid-rows-[62px_128px_1fr] gap-4 h-[calc(100vh-20px-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height))]"
  493. >
  494. <DeptTreeSelect
  495. :deptId="id"
  496. :top-id="158"
  497. v-model="query.deptId"
  498. @node-click="handleDeptNodeClick"
  499. class="row-span-3"
  500. />
  501. <!-- <div class="p-4 bg-white dark:bg-[#1d1e1f] shadow rounded-lg row-span-3"> </div> -->
  502. <el-form
  503. size="default"
  504. class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow px-8 gap-8 flex items-center justify-between"
  505. >
  506. <div class="flex items-center gap-8">
  507. <el-form-item label="项目">
  508. <el-input
  509. v-model="query.contractName"
  510. placeholder="请输入项目"
  511. clearable
  512. @keyup.enter="handleQuery()"
  513. class="!w-240px"
  514. />
  515. </el-form-item>
  516. <el-form-item label="任务">
  517. <el-input
  518. v-model="query.taskName"
  519. placeholder="请输入任务"
  520. clearable
  521. @keyup.enter="handleQuery()"
  522. class="!w-240px"
  523. />
  524. </el-form-item>
  525. <el-form-item label="创建时间">
  526. <el-date-picker
  527. v-model="query.createTime"
  528. value-format="YYYY-MM-DD HH:mm:ss"
  529. type="daterange"
  530. start-placeholder="开始日期"
  531. end-placeholder="结束日期"
  532. :shortcuts="rangeShortcuts"
  533. class="!w-220px"
  534. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  535. />
  536. </el-form-item>
  537. </div>
  538. <el-form-item>
  539. <el-button type="primary" @click="handleQuery()">
  540. <Icon icon="ep:search" class="mr-5px" /> 搜索
  541. </el-button>
  542. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  543. </el-form-item>
  544. </el-form>
  545. <div class="grid grid-cols-8 gap-8">
  546. <div
  547. v-for="info in totalWorkKeys"
  548. :key="info[0]"
  549. class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow p-4 flex flex-col items-center justify-center gap-2"
  550. >
  551. <div class="size-7.5" :class="info[3]"></div>
  552. <count-to
  553. class="text-2xl font-medium"
  554. :start-val="0"
  555. :end-val="totalWork[info[0]]"
  556. :decimals="info[4]"
  557. @click="info[2] === '未填报' ? openUnfilledDialog() : ''"
  558. >
  559. <span class="text-xs leading-8 text-[var(--el-text-color-regular)]">暂无数据</span>
  560. </count-to>
  561. <div class="text-sm font-medium text-[var(--el-text-color-regular)] whitespace-nowrap">
  562. {{ info[1] ? info[2] + '(' + info[1] + ')' : info[2] }}
  563. </div>
  564. </div>
  565. </div>
  566. <div class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow flex flex-col p-4 gap-2">
  567. <div class="flex h-12 items-center justify-between">
  568. <el-button-group>
  569. <el-button
  570. size="default"
  571. :type="tab === '表格' ? 'primary' : 'default'"
  572. @click="handleSelectTab('表格')"
  573. >表格
  574. </el-button>
  575. <el-button
  576. size="default"
  577. :type="tab === '看板' ? 'primary' : 'default'"
  578. @click="handleSelectTab('看板')"
  579. >看板
  580. </el-button>
  581. </el-button-group>
  582. <h3 class="text-xl font-medium">{{ `${deptName}-${tab}` }}</h3>
  583. <el-button size="default" type="primary" @click="exportAll">导出</el-button>
  584. </div>
  585. <div class="flex-1 relative">
  586. <el-auto-resizer class="absolute">
  587. <template #default="{ height }">
  588. <Motion
  589. as="div"
  590. :style="{ position: 'relative', overflow: 'hidden' }"
  591. :animate="{ height: `${height}px`, width: `100%` }"
  592. :transition="{ type: 'spring', stiffness: 200, damping: 25, duration: 0.3 }"
  593. >
  594. <AnimatePresence :initial="false" mode="sync">
  595. <Motion
  596. :key="currentTab"
  597. as="div"
  598. :initial="{ x: direction === 'left' ? '-100%' : '100%', opacity: 0 }"
  599. :animate="{ x: '0%', opacity: 1 }"
  600. :exit="{ x: direction === 'left' ? '50%' : '-50%', opacity: 0 }"
  601. :transition="{ type: 'tween', stiffness: 300, damping: 30, duration: 0.3 }"
  602. :style="{ position: 'absolute', left: 0, right: 0, top: 0 }"
  603. >
  604. <div :style="{ width: `100%`, height: `${height}px` }">
  605. <zm-table
  606. v-if="currentTab === '表格'"
  607. :loading="listLoading"
  608. :data="list"
  609. :height="height"
  610. show-border
  611. >
  612. <template v-for="item in columns(type)" :key="item.prop">
  613. <zm-table-column
  614. v-if="item.prop !== 'name' && item.prop !== 'nonProductiveTime'"
  615. :label="item.label"
  616. :prop="item.prop"
  617. :formatter="formatter"
  618. />
  619. <zm-table-column
  620. v-else-if="item.prop === 'name'"
  621. :label="item.label"
  622. :prop="item.prop"
  623. >
  624. <template #default="{ row }">
  625. <el-button text type="primary" @click.prevent="tolist(row.id)">{{
  626. row.name
  627. }}</el-button>
  628. </template>
  629. </zm-table-column>
  630. <zm-table-column v-else :label="item.label" :prop="item.prop">
  631. <template #default="{ row }">
  632. <el-button
  633. v-if="row.nonProductiveTime > 0"
  634. text
  635. type="primary"
  636. @click.prevent="tolist(row.id, true)"
  637. >
  638. {{ (Number(row.nonProductiveTime ?? 0) * 100).toFixed(2) + '%' }}
  639. </el-button>
  640. <span v-else>
  641. {{ (Number(row.nonProductiveTime ?? 0) * 100).toFixed(2) + '%' }}
  642. </span>
  643. </template>
  644. </zm-table-column>
  645. </template>
  646. </zm-table>
  647. <div
  648. ref="chartRef"
  649. v-loading="chartLoading"
  650. :key="dayjs().valueOf()"
  651. v-else
  652. :style="{ width: `100%`, height: `${height}px` }"
  653. >
  654. </div>
  655. </div>
  656. </Motion>
  657. </AnimatePresence>
  658. </Motion>
  659. </template>
  660. </el-auto-resizer>
  661. </div>
  662. </div>
  663. </div>
  664. <UnfilledReportDialog ref="unfilledDialogRef" :query-params="query" />
  665. </template>
  666. <style scoped>
  667. :deep(.el-form-item) {
  668. margin-bottom: 0;
  669. }
  670. :deep(.el-table) {
  671. border-top-right-radius: 8px;
  672. border-top-left-radius: 8px;
  673. .el-table__cell {
  674. height: 52px;
  675. }
  676. .el-table__header-wrapper {
  677. .el-table__cell {
  678. background: var(--el-fill-color-light);
  679. }
  680. }
  681. }
  682. </style>