2 changed files with 80 additions and 3 deletions
@ -0,0 +1,65 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
import { reactive } from "vue"; |
||||
|
import { ElProgress } from "element-plus"; |
||||
|
import { type ICellRendererParams, } from "ag-grid-enterprise"; |
||||
|
import { Typeof } from "@ease-forge/shared"; |
||||
|
|
||||
|
// 定义组件选项 |
||||
|
defineOptions({ |
||||
|
name: 'Progress', |
||||
|
}); |
||||
|
|
||||
|
// 定义 Props 类型 |
||||
|
interface ProgressProps { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** 单元格组件Props */ |
||||
|
interface CellComponentProps<T = {}> { |
||||
|
params: ICellRendererParams<any, any, any> & T; |
||||
|
} |
||||
|
|
||||
|
// 读取组件 props 属性 |
||||
|
const props = defineProps<CellComponentProps<ProgressProps>>(); |
||||
|
|
||||
|
// 定义 State 类型 |
||||
|
interface ProgressState { |
||||
|
} |
||||
|
|
||||
|
// state 属性 |
||||
|
const state = reactive<ProgressState>({}); |
||||
|
|
||||
|
const params = props.params; |
||||
|
const progressVal = params?.data?.progressVal ?? 0; |
||||
|
const progressSum = params?.data?.progressSum; |
||||
|
|
||||
|
export type { |
||||
|
ProgressProps, |
||||
|
ProgressState, |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<ElProgress |
||||
|
v-if="Typeof.isNum(progressSum)" |
||||
|
class="ag-cell-progress flex-item-fill" |
||||
|
:percentage="progressVal/(Math.max(progressSum, 1))*100" |
||||
|
:textInside="true" |
||||
|
:format="()=>`${progressVal}/${progressSum}`" |
||||
|
:striped="true" |
||||
|
:stripedFlow="true" |
||||
|
:strokeWidth="18" |
||||
|
/> |
||||
|
</template> |
||||
|
|
||||
|
<style> |
||||
|
.ag-cell-value:has(> .ag-cell-progress), .ag-group-value:has(> .ag-cell-progress) { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
} |
||||
|
|
||||
|
.ag-cell-progress .el-progress-bar__innerText { |
||||
|
color: #434343; |
||||
|
} |
||||
|
</style> |
||||
Loading…
Reference in new issue