mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-09-22 04:42:02 +08:00
refactor: 更新表单组件以增强上传功能和验证逻辑
- 在 step1.vue、step2.vue 和 step3.vue 中添加上传规则和删除功能 - 优化照片上传的处理逻辑,确保上传后能正确恢复表单状态 - 更新表单验证逻辑,使用 async/await 处理验证过程 - 修改样式以提升用户体验,确保上传组件的可用性和一致性
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="wrapper" :style="themeStyle">
|
||||
<up-form label-position="top" :model="form" ref="uForm">
|
||||
<up-form label-position="top" :model="form" :rules="rules" ref="uForm">
|
||||
<div class="column">
|
||||
<div class="flag-title light-color">基础信息</div>
|
||||
<up-form-item
|
||||
@@ -48,8 +48,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { onReady } from '@dcloudio/uni-app'
|
||||
import { ref, reactive, computed, watch, onMounted } from 'vue'
|
||||
import { useStore } from '@/store'
|
||||
import { applySecond } from '@/api/entry'
|
||||
import { getThemeStyle } from '@/utils/theme'
|
||||
@@ -96,24 +95,25 @@ watch(
|
||||
{ deep: true, immediate: true }
|
||||
)
|
||||
|
||||
onReady(() => {
|
||||
onMounted(() => {
|
||||
uForm.value?.setRules(rules)
|
||||
})
|
||||
|
||||
function validatorStep2Form() {
|
||||
uForm.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
const params = { ...form }
|
||||
const res = await applySecond(params)
|
||||
if (res.data.success) {
|
||||
uni.showToast({
|
||||
title: '提交成功!',
|
||||
icon: 'none',
|
||||
})
|
||||
emit('callback')
|
||||
}
|
||||
}
|
||||
})
|
||||
async function validatorStep2Form() {
|
||||
try {
|
||||
await uForm.value?.validate()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
const params = { ...form }
|
||||
const res = await applySecond(params)
|
||||
if (res.data.success) {
|
||||
uni.showToast({
|
||||
title: '提交成功!',
|
||||
icon: 'none',
|
||||
})
|
||||
emit('callback')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user