cxc-szcx-uniapp/pages/views/shengchan/ribaoshuju/rbsjLsxq.vue

51 lines
1.4 KiB
Vue

<template>
<view>
<cxc-szcx-dateRangeSelect v-model="dateRange"></cxc-szcx-dateRangeSelect>
</view>
</template>
<script setup>
import { ref, onMounted, computed, nextTick, watchEffect } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { queryYearShengchansj } from '@/api/shengchan.js';
import { formatDate, getDateAfterDays, getDateAfterMonths } from '@/utils/dateTime.js';
const name = ref({});
const dateRange = ref([]);
const dataList = ref([]);
const endDate = ref('');
const startDate = ref('');
const getYearShengchansj = () => {
let queryParms = {};
dataList.value = [];
queryParms.yearStart = formatDate(dateRange[0]);
queryParms.yearEnd = formatDate(dateRange[1]);
// console.log(queryParms);
queryYearShengchansj(queryParms).then((res) => {
if (res.success) {
console.log(res);
dataList.value = res.result.records;
}
});
};
onMounted(() => {
const now = new Date();
if (now.getHours() < 11) {
endDate.value = getDateAfterDays(now, -1); //11点之前 头一天的数据
startDate.value = getDateAfterMonths(endDate.value, -1); //11点之前 头一天的数据
} else {
endDate.value = now;
startDate.value = getDateAfterMonths(endDate.value, -1); //11点之前 头一天的数据
}
dateRange.value = [startDate.value, endDate.value];
getYearShengchansj();
});
onLoad((options) => {
name.value = options.data;
});
</script>
<style></style>