diff --git a/gold-system/.env.development b/gold-system/.env.development index e9f1785..cd0100f 100644 --- a/gold-system/.env.development +++ b/gold-system/.env.development @@ -2,4 +2,4 @@ # VITE_API_BASE='http://192.168.8.94:8080/' VITE_API_BASE='https://hwjb.homilychart.com/gold_htms_dev' # VITE_API_BASE='http://54.251.137.151:10704/' -# VITE_API_BASE='http://192.168.8.220:8080/' +# VITE_API_BASE='http://192.168.8.232:8080/' diff --git a/gold-system/.env.production b/gold-system/.env.production index 70912af..5670e06 100644 --- a/gold-system/.env.production +++ b/gold-system/.env.production @@ -1,5 +1,5 @@ # VITE_API_BASE='http://54.251.137.151:10702/' VITE_API_BASE='https://hwjb.homilychart.com/gold_htms_prod' # VITE_API_BASE='https://hwjb.homilychart.com/gold_htms_dev' -# VITE_API_BASE='http://192.168.8.220:8080/' +# VITE_API_BASE='http://192.168.8.232:8080/' diff --git a/gold-system/src/views/managerecharge/rate.vue b/gold-system/src/views/managerecharge/rate.vue index 2a4b7e3..d4800f4 100644 --- a/gold-system/src/views/managerecharge/rate.vue +++ b/gold-system/src/views/managerecharge/rate.vue @@ -42,35 +42,63 @@ const getObj = ref({ const total = ref(0) //分页总条目 -// 时间选择器 -// const value1 = ref([]) // 时间数组 -// function handleDateChange(value) { -// if (value && value.length === 2) { -// value1.value.startTime = value[0] // 开始日期 -// value1.value.endTime = value[1] // 结束日期 -// } -// console.log(value1) -// } - -const time = ref({}) + +// 替换原来的time,用数组 +const timeRange = ref([]) + +// 格式化日期为YYYY-MM-DD HH:mm:ss,否则格式不对无法填充日期时间选择器 +const formatDateTime = (date) => { + return moment(date).format('YYYY-MM-DD HH:mm:ss') +} + +// 今天 +const getToday = () => { + const today = new Date() + const start = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0) + const end = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1, 0, 0, 0) + timeRange.value = [formatDateTime(start), formatDateTime(end)] + search() +} + +// 昨天 +const getYesterday = () => { + const yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) + const start = new Date(yesterday.getFullYear(), yesterday.getMonth(), yesterday.getDate(), 0, 0, 0) + const end = new Date(yesterday.getFullYear(), yesterday.getMonth(), yesterday.getDate() + 1, 0, 0, 0) + timeRange.value = [formatDateTime(start), formatDateTime(end)] + search() +} + +// 近 7 天 +const get7Days = () => { + const today = new Date() + const start = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 6, 0, 0, 0) + const end = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1, 0, 0, 0) + timeRange.value = [formatDateTime(start), formatDateTime(end)] + search() +} + const get = async function (val) { - // 搜索参数时间赋值 - // if (value1.value && value1.value.length === 2) { - // time.value.startTime = value1.value[0]; - // time.value.endTime = value1.value[1]; - // } else { - // time.value.startTime = ''; - // time.value.endTime = ''; - // } try { // 搜索参数页码赋值 if (typeof val === 'number') { getObj.value.pageNum = val; } + // 时间赋值 + const time = {} + if (timeRange.value.length === 2) { + time.startTime = moment(timeRange.value[0]).format('YYYY-MM-DD HH:mm:ss') + time.endTime = moment(timeRange.value[1]).format('YYYY-MM-DD HH:mm:ss') + } else { + time.startTime = '' + time.endTime = '' + } + console.log('搜索参数', { ...getObj.value, - rate: { ...time.value } + rate: { ...time } }); // 发送POST请求 const result = await request({ @@ -78,7 +106,7 @@ const get = async function (val) { method: 'POST', data: { ...getObj.value, - rate: { ...time.value } + rate: { ...time } } }); @@ -96,41 +124,6 @@ const get = async function (val) { } } -// 今天 -const getToday = () => { - const today = new Date() - // 格式化开始时间 - const startDate = moment(today).startOf('day').format('YYYY-MM-DD HH:mm:ss') - // 格式化结束时间,将结束时间设为当天 00:00:00 - const endDate = moment(today).add(1, 'days').startOf('day').format('YYYY-MM-DD HH:mm:ss') - time.value.startTime = startDate - time.value.endTime = endDate - search() -} - -// 昨天 -const getYesterday = () => { - const yesterday = moment().subtract(1, 'days') - // 格式化开始时间 - const startDate = yesterday.startOf('day').format('YYYY-MM-DD HH:mm:ss') - // 格式化结束时间,将结束时间设为当天 00:00:00 - const endDate = yesterday.add(1, 'days').startOf('day').format('YYYY-MM-DD HH:mm:ss') - time.value.startTime = startDate - time.value.endTime = endDate - search() -} - -// 近7天 -const get7Days = () => { - // 格式化开始时间 - const startDate = moment().subtract(6, 'days').startOf('day').format('YYYY-MM-DD HH:mm:ss') - // 格式化结束时间,将结束时间设为当天 00:00:00 - const endDate = moment().add(1, 'days').startOf('day').format('YYYY-MM-DD HH:mm:ss') - time.value.startTime = startDate - time.value.endTime = endDate - search() -} - // 搜索 const search = function () { getObj.value.pageNum = 1 @@ -414,8 +407,7 @@ const rules = reactive({ // 重置的按钮 const handledelete = function () { - time.value.startTime = '' - time.value.endTime = '' + timeRange.value={} getObj.value.pageNum = 1 } // 验证跳转输入框的数字是否合法 @@ -494,27 +486,16 @@ function handleInput(value) {
个