稳态指标合格率

This commit is contained in:
仲么了
2024-02-28 18:47:52 +08:00
parent 9e288b49be
commit b9fef6cde0
5 changed files with 311 additions and 143 deletions

View File

@@ -451,7 +451,39 @@ const setTimeOptions = (list: any) => {
timeOptions.value = list
}
defineExpose({ timeValue, interval, timeFlag, setTimeOptions })
// 获取时间范围的同比
function getYearOnYear(startDate: string, endDate: string): [string, string] {
const startYearAgo = new Date(startDate)
startYearAgo.setFullYear(startYearAgo.getFullYear() - 1)
const endYearAgo = new Date(endDate)
endYearAgo.setFullYear(endYearAgo.getFullYear() - 1)
return [formatDate(startYearAgo), formatDate(endYearAgo)]
}
// 获取时间范围的环比
function getMonthOnMonth(startDate: string, endDate: string): [string, string] {
const start = new Date(startDate)
const end = new Date(endDate)
const diffTime = end.getTime() - start.getTime() + 60 * 60 * 24 * 1000 // 计算时间差
const startMonthAgo = new Date(start)
startMonthAgo.setTime(startMonthAgo.getTime() - diffTime) // 将开始时间向前推移相同的时间差
const endMonthAgo = new Date(start)
endMonthAgo.setDate(start.getDate() - 1) // 结束时间是开始时间的前一天
return [formatDate(startMonthAgo), formatDate(endMonthAgo)]
}
// 格式化日期为 YYYY-MM-DD
function formatDate(date: Date): string {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
defineExpose({ timeValue, interval, timeFlag, setTimeOptions, getYearOnYear, getMonthOnMonth })
</script>
<style scoped>

View File

@@ -137,11 +137,8 @@ const pageSizes = computed(() => {
* 记录选择的项
*/
const selectChangeEvent: VxeTableEvents.CheckboxChange<any> = ({ checked }) => {
const $table = tableRef.value
if ($table) {
const records = $table.getCheckboxRecords()
tableStore.onTableAction('selection-change', records)
}
const records = (tableRef.value as VxeTableInstance).getCheckboxRecords()
tableStore.onTableAction('selection-change', records)
}
const getRef = () => {