fix(createActivity): 修复日期格式化和默认选择索引问题
修复moment.js日期格式化方法错误,将dates()改为date() 为发布状态、活动方式和公开显示添加默认选择索引,确保表单初始化时正确显示
Showing
1 changed file
with
16 additions
and
6 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-21 16:04:10 | 2 | * @Date: 2022-09-21 16:04:10 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-08-18 22:11:06 | 4 | + * @LastEditTime: 2025-08-18 23:11:40 |
| 5 | * @FilePath: /swx/src/pages/createActivity/index.vue | 5 | * @FilePath: /swx/src/pages/createActivity/index.vue |
| 6 | * @Description: 创建活动页面 | 6 | * @Description: 创建活动页面 |
| 7 | --> | 7 | --> |
| ... | @@ -278,18 +278,18 @@ | ... | @@ -278,18 +278,18 @@ |
| 278 | </van-popup> | 278 | </van-popup> |
| 279 | <!-- 是否发布弹出框 --> | 279 | <!-- 是否发布弹出框 --> |
| 280 | <van-popup :show="show_publish_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true"> | 280 | <van-popup :show="show_publish_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true"> |
| 281 | - <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="columns" toolbar-class="picker-toolbar" :defaultIndex="0" | 281 | + <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="columns" toolbar-class="picker-toolbar" :defaultIndex="defaultPublishIndex" |
| 282 | @confirm="onPublishConfirm" @cancel="onPublishCancel" @change="onPublishChange" /> | 282 | @confirm="onPublishConfirm" @cancel="onPublishCancel" @change="onPublishChange" /> |
| 283 | </van-popup> | 283 | </van-popup> |
| 284 | <!-- 活动方式弹出框 --> | 284 | <!-- 活动方式弹出框 --> |
| 285 | <van-popup :show="show_activity_type_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true"> | 285 | <van-popup :show="show_activity_type_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true"> |
| 286 | - <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="activity_type_columns" :defaultIndex="0" | 286 | + <van-picker :show-toolbar="true" title="" confirm-button-text="确定" :columns="activity_type_columns" :defaultIndex="defaultActivityTypeIndex" |
| 287 | toolbar-class="picker-toolbar" @confirm="onActivityTypeConfirm" @cancel="onActivityTypeCancel" | 287 | toolbar-class="picker-toolbar" @confirm="onActivityTypeConfirm" @cancel="onActivityTypeCancel" |
| 288 | @change="onActivityTypeChange" /> | 288 | @change="onActivityTypeChange" /> |
| 289 | </van-popup> | 289 | </van-popup> |
| 290 | <!-- 是否公开显示弹出框 --> | 290 | <!-- 是否公开显示弹出框 --> |
| 291 | <van-popup :show="show_public_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true"> | 291 | <van-popup :show="show_public_popup" position="bottom" custom-style="height: 50%;" :lock-scroll="true"> |
| 292 | - <van-picker :show-toolbar="true" confirm-button-text="确定" title="" :columns="public_type_columns" :defaultIndex="0" | 292 | + <van-picker :show-toolbar="true" confirm-button-text="确定" title="" :columns="public_type_columns" :defaultIndex="defaultPublicTypeIndex" |
| 293 | toolbar-class="picker-toolbar" @confirm="onPublicTypeConfirm" @cancel="onPublicTypeCancel" | 293 | toolbar-class="picker-toolbar" @confirm="onPublicTypeConfirm" @cancel="onPublicTypeCancel" |
| 294 | @change="onPublicTypeChange" /> | 294 | @change="onPublicTypeChange" /> |
| 295 | </van-popup> | 295 | </van-popup> |
| ... | @@ -881,7 +881,7 @@ const onSubmit = async () => { | ... | @@ -881,7 +881,7 @@ const onSubmit = async () => { |
| 881 | const formatInfoDate = (date) => { | 881 | const formatInfoDate = (date) => { |
| 882 | const formatYear = moment(date).year(); | 882 | const formatYear = moment(date).year(); |
| 883 | const formatMonth = moment(date).month(); | 883 | const formatMonth = moment(date).month(); |
| 884 | - const formatDay = moment(date).dates(); | 884 | + const formatDay = moment(date).date(); |
| 885 | const formatHour = moment(date).hour(); | 885 | const formatHour = moment(date).hour(); |
| 886 | const formatMin = moment(date).minute() | 886 | const formatMin = moment(date).minute() |
| 887 | return new Date(formatYear, formatMonth, formatDay, formatHour, formatMin); | 887 | return new Date(formatYear, formatMonth, formatDay, formatHour, formatMin); |
| ... | @@ -889,6 +889,9 @@ const formatInfoDate = (date) => { | ... | @@ -889,6 +889,9 @@ const formatInfoDate = (date) => { |
| 889 | 889 | ||
| 890 | // 获取活动信息,还原 | 890 | // 获取活动信息,还原 |
| 891 | const defaultIndex = ref(0); | 891 | const defaultIndex = ref(0); |
| 892 | +const defaultPublishIndex = ref(0); | ||
| 893 | +const defaultActivityTypeIndex = ref(0); | ||
| 894 | +const defaultPublicTypeIndex = ref(0); | ||
| 892 | const html_content = ref(''); | 895 | const html_content = ref(''); |
| 893 | const activity_id = ref(''); | 896 | const activity_id = ref(''); |
| 894 | const updateActivityInfo = async ({ activity, host }) => { | 897 | const updateActivityInfo = async ({ activity, host }) => { |
| ... | @@ -951,13 +954,20 @@ const updateActivityInfo = async ({ activity, host }) => { | ... | @@ -951,13 +954,20 @@ const updateActivityInfo = async ({ activity, host }) => { |
| 951 | // 是否发布 | 954 | // 是否发布 |
| 952 | publish_status.value = activity.status === 'disable' ? '暂不发布' : '立即发布'; | 955 | publish_status.value = activity.status === 'disable' ? '暂不发布' : '立即发布'; |
| 953 | status.value = activity.status; | 956 | status.value = activity.status; |
| 957 | + // 设置发布状态默认索引 | ||
| 958 | + defaultPublishIndex.value = activity.status === 'disable' ? 0 : 1; | ||
| 954 | // 活动方法 | 959 | // 活动方法 |
| 955 | - activity_type.value = activity.status === 'offline' ? '现场活动' : '线上活动'; | 960 | + activity_type.value = activity.mode === 'offline' ? '现场活动' : '线上活动'; |
| 961 | + mode.value = activity.mode; | ||
| 962 | + // 设置活动方式默认索引 | ||
| 963 | + defaultActivityTypeIndex.value = activity.mode === 'offline' ? 0 : 1; | ||
| 956 | // 活动地址 | 964 | // 活动地址 |
| 957 | address.value = activity.address; | 965 | address.value = activity.address; |
| 958 | // 是否公开显示 | 966 | // 是否公开显示 |
| 959 | public_type.value = activity.is_public === 0 ? '不公开' : '公开'; | 967 | public_type.value = activity.is_public === 0 ? '不公开' : '公开'; |
| 960 | is_public.value = activity.is_public; | 968 | is_public.value = activity.is_public; |
| 969 | + // 设置公开显示默认索引 | ||
| 970 | + defaultPublicTypeIndex.value = activity.is_public === 0 ? 0 : 1; | ||
| 961 | // | 971 | // |
| 962 | is_inner.value = activity.is_inner ? true : false; | 972 | is_inner.value = activity.is_inner ? true : false; |
| 963 | is_black.value = activity.is_black ? true : false; | 973 | is_black.value = activity.is_black ? true : false; | ... | ... |
-
Please register or login to post a comment