huanzi-vue/src/views/zh/hy/zc/index.vue

85 lines
2.6 KiB
Vue
Raw Normal View History

2025-07-01 15:46:20 +08:00
<template>
<div class="p-4">
<a-card :bordered="false" style="height: 100%">
<a-row>
<a-col :span="10">
<a-date-picker :value-format="valueFormat" :default-value="defaultValue" v-model:value="parmas.dateString" @change="changeDate" />
2025-07-02 15:04:03 +08:00
<a-select ref="select"
placeholder="请选区域"
v-model:value="parmas.housingestateId"
style="width: 200px;margin-left: 5px;"
@change="handleHousinges">
<a-select-option value="" >全部</a-select-option>
<a-select-option :value="item.housingestateId" v-for="item in housingestates" :key="item.housingestateId">{{item.housingestateName}}</a-select-option>
</a-select>
2025-07-01 15:46:20 +08:00
</a-col>
</a-row>
2025-07-02 15:04:03 +08:00
<Bar :chartData="dataSource" height="80vh" :option="{ title: { text: '会员注册时间段统计', left: 'center' }}" :itemStyle="{ normal: {label : {show: true, position: 'top'}}}" :seriesName="'个数'"></Bar>
2025-07-01 15:46:20 +08:00
</a-card>
</div>
</template>
<script lang="ts" setup>
import {ref, unref, reactive, onMounted} from 'vue';
import Bar from '/@/components/chart/Bar.vue';
2025-07-02 15:04:03 +08:00
import { registerList,housingestateList } from '../hy.api';
2025-07-01 15:46:20 +08:00
import type { Dayjs } from 'dayjs';
const valueFormat = 'YYYY-MM-DD';
const dataSource = ref([]);
const dateValue = ref();
2025-07-02 15:04:03 +08:00
const housingestates = ref();
async function getHousingestates(){
housingestates.value = await housingestateList();
}
2025-07-01 15:46:20 +08:00
const parmas = reactive<any>({
beginTime: '',
endTime: '',
dateString: '',
housingestateId: '',
})
const changeDate = (date, dateString) => {
parmas.dateString = dateString;
2025-07-02 15:04:03 +08:00
loadDate();
2025-07-01 15:46:20 +08:00
};
2025-07-02 15:04:03 +08:00
function handleHousinges(){
loadDate();
};
2025-07-01 15:46:20 +08:00
async function loadDate() {
if(parmas.dateString!=''){
parmas.beginTime = parmas.dateString+' 00:00:00';
parmas.endTime = parmas.dateString+' 23:59:59';
}
const res = await registerList(parmas);
dataSource.value = [];
for (let i = 0; i < res.length; i++) {
dataSource.value.push({
name: `${res[i].shortHour}`,
value: res[i].cn,
});
}
}
2025-07-02 15:04:03 +08:00
function getCurrent(){
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份+10-indexed并补零
const day = String(date.getDate()).padStart(2, '0'); // 日期补零
const formattedDate = `${year}-${month}-${day}`;
return formattedDate;
}
2025-07-01 15:46:20 +08:00
onMounted(() => {
2025-07-02 15:04:03 +08:00
getHousingestates();
2025-07-01 15:46:20 +08:00
if(parmas.dateString==''){
2025-07-02 15:04:03 +08:00
parmas.dateString=getCurrent();
2025-07-01 15:46:20 +08:00
}
loadDate();
})
</script>