Browse Source

时间选择器问题

milestone-20251021-双11活动后台
liruiqiang 3 months ago
parent
commit
e692324cdf
  1. 45
      src/views/admin/landingDetail.vue
  2. 18
      src/views/admin/landingList.vue

45
src/views/admin/landingDetail.vue

@ -111,15 +111,13 @@
</template>
<script>
import { getLandingListApi, exportLandingDetailApi } from '../../api/member.js';
import { getLandingDetailApi, exportLandingDetailApi } from '../../api/member.js';
import { ElMessage } from 'element-plus';
export default {
name: 'LandingDetail',
data() {
return {
//
detailData: '详情',
//
filterForm: {
startTime: '',
@ -167,7 +165,7 @@ export default {
const activityId = this.$route.params.id;
if (activityId) {
//
this.getActivityDetail(activityId);
this.getLandingDetail(activityId);
} else {
ElMessage.error('未获取到活动ID,无法加载详情');
}
@ -178,15 +176,30 @@ export default {
this.$router.back();
},
//
async getActivityDetail(id) {
// 'YYYY-MM-DD HH:mm:ss'
formatDateTime(date) {
if (!date) return '';
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
//
async getLandingDetail(id) {
this.loading = true;
try {
const res = await getLandingListApi({
id: id, // ID
const { startTime, endTime, status } = this.filterForm;
const res = await getLandingDetailApi({
id: id,
page: this.currentPage,
pageSize: this.pageSize,
...this.filterForm
startTime: this.formatDateTime(startTime),
endTime: this.formatDateTime(endTime),
status: status
});
if (res.code === 200) {
@ -205,17 +218,19 @@ export default {
//
handleQuery() {
this.currentPage = 1;
this.getActivityDetail(this.$route.params.id);
this.getLandingDetail(this.$route.params.id);
},
//
handleExport() {
this.loading = true;
try {
// ID
const { startTime, endTime, status } = this.filterForm;
exportLandingDetailApi({
id: this.$route.params.id,
...this.filterForm
startTime: this.formatDateTime(startTime),
endTime: this.formatDateTime(endTime),
status: status
}).then(res => {
if (res.code === 200) {
ElMessage.success('导出成功');
@ -224,7 +239,7 @@ export default {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${this.detailData?.name || '活动数据'}.xlsx`;
a.download = `${'活动数据'}.xlsx`;
a.click();
URL.revokeObjectURL(url);
} else {
@ -242,13 +257,13 @@ export default {
handleSizeChange(val) {
this.pageSize = val;
this.currentPage = 1;
this.getActivityDetail(this.$route.params.id);
this.getLandingDetail(this.$route.params.id);
},
//
handleCurrentChange(val) {
this.currentPage = val;
this.getActivityDetail(this.$route.params.id);
this.getLandingDetail(this.$route.params.id);
}
}
}

18
src/views/admin/landingList.vue

@ -383,6 +383,18 @@ export default {
reader.readAsDataURL(file.raw);
},
// 'YYYY-MM-DD HH:mm:ss'
formatDateTime(date) {
if (!date) return '';
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
// /
submitForm() {
this.$refs.formRef.validate((valid) => {
@ -392,15 +404,15 @@ export default {
id: this.form.id,
name: this.form.name,
intro: this.form.intro,
startTime: this.form.startTime,
endTime: this.form.endTime,
startTime: formatDateTime(this.form.startTime),
endTime: formatDateTime(this.form.endTime),
landingPage: this.form.landingPage,
popup: this.form.popup
}).then(res => {
if (res.code === 200) {
ElMessage.success('操作成功');
this.dialogVisible = false;
this.getLandingList(); //
this.getLandingList();
} else {
ElMessage.error(res.msg || '操作失败');
}

Loading…
Cancel
Save