修复表单弹窗误关闭
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BaseModal v-model="productModalVisible" title="选择预约作品">
|
||||
<BaseModal v-model="productModalVisible" title="选择预约作品" :has-unsaved-changes="manualProductChanged">
|
||||
<div class="product-modal">
|
||||
<input v-model.trim="productKeyword" class="search-input" placeholder="搜索作品" @input="filterProducts" />
|
||||
<div class="list">
|
||||
@@ -143,6 +143,14 @@ const timeSelectTip = ref('请先选择美甲师并填写时长')
|
||||
const conflictTip = ref('')
|
||||
const conflictLevel = ref<'free' | 'danger'>('free')
|
||||
const loading = ref(false)
|
||||
const manualProductChanged = computed(() => {
|
||||
return Boolean(
|
||||
form.manualProductTitle
|
||||
|| form.manualProductPrice
|
||||
|| form.manualProductTags
|
||||
|| form.manualProductDescription
|
||||
)
|
||||
})
|
||||
|
||||
const selectedProductTitle = computed(() => {
|
||||
if (selectedProduct.value) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<button class="fab" type="button" @click="openCreate">+</button>
|
||||
|
||||
<BaseModal v-model="createModalVisible" title="新增客户">
|
||||
<BaseModal v-model="createModalVisible" title="新增客户" :has-unsaved-changes="createFormChanged">
|
||||
<div class="modal-form">
|
||||
<div class="field">
|
||||
<label class="required">客户姓名</label>
|
||||
@@ -40,7 +40,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import BaseModal from '@/components/BaseModal.vue'
|
||||
import EmptyState from '@/components/EmptyState.vue'
|
||||
@@ -58,6 +58,7 @@ const customers = ref<UserInfo[]>([])
|
||||
const createModalVisible = ref(false)
|
||||
const creating = ref(false)
|
||||
const createForm = reactive({ nickname: '', phone: '' })
|
||||
const createFormChanged = computed(() => Boolean(createForm.nickname || createForm.phone))
|
||||
|
||||
const loadCustomers = async (): Promise<void> => {
|
||||
loading.value = true
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<button class="fab" type="button" @click="openCreate">+</button>
|
||||
|
||||
<BaseModal v-model="createModalVisible" title="新增员工">
|
||||
<BaseModal v-model="createModalVisible" title="新增员工" :has-unsaved-changes="createFormChanged">
|
||||
<div class="modal-form">
|
||||
<div class="field"><label class="required">姓名</label><input v-model.trim="createForm.nickname" placeholder="请输入姓名" /></div>
|
||||
<div class="field"><label class="required">手机号</label><input v-model.trim="createForm.phone" inputmode="numeric" placeholder="请输入手机号" /></div>
|
||||
@@ -35,7 +35,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import BaseModal from '@/components/BaseModal.vue'
|
||||
import EmptyState from '@/components/EmptyState.vue'
|
||||
@@ -58,6 +58,9 @@ const createForm = reactive({
|
||||
password: '',
|
||||
wechatId: ''
|
||||
})
|
||||
const createFormChanged = computed(() => {
|
||||
return Boolean(createForm.nickname || createForm.phone || createForm.account || createForm.password || createForm.wechatId)
|
||||
})
|
||||
|
||||
const loadEmployees = async (): Promise<void> => {
|
||||
loading.value = true
|
||||
|
||||
@@ -24,7 +24,12 @@
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<BaseModal v-model="editModalVisible" title="个人信息" :close-disabled="profileSaving || avatarUploading">
|
||||
<BaseModal
|
||||
v-model="editModalVisible"
|
||||
title="个人信息"
|
||||
:close-disabled="profileSaving || avatarUploading"
|
||||
:has-unsaved-changes="profileFormChanged"
|
||||
>
|
||||
<div class="profile-avatar-row">
|
||||
<img v-if="profileForm.avatar" class="profile-avatar profile-avatar--image" :src="profileForm.avatar" alt="头像" />
|
||||
<div v-else class="profile-avatar">头像</div>
|
||||
@@ -109,6 +114,13 @@ const profileForm = reactive({
|
||||
wechatId: '',
|
||||
signature: ''
|
||||
})
|
||||
const profileBaseline = reactive({
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
contactPhone: '',
|
||||
wechatId: '',
|
||||
signature: ''
|
||||
})
|
||||
|
||||
const menus: ProfileMenu[] = [
|
||||
{ title: '个人信息', action: 'editProfile' },
|
||||
@@ -164,9 +176,22 @@ const openEditProfile = (): void => {
|
||||
profileForm.contactPhone = profile.contactPhone || ''
|
||||
profileForm.wechatId = profile.wechatId || ''
|
||||
profileForm.signature = profile.signature || ''
|
||||
profileBaseline.nickname = profileForm.nickname
|
||||
profileBaseline.avatar = profileForm.avatar
|
||||
profileBaseline.contactPhone = profileForm.contactPhone
|
||||
profileBaseline.wechatId = profileForm.wechatId
|
||||
profileBaseline.signature = profileForm.signature
|
||||
editModalVisible.value = true
|
||||
}
|
||||
|
||||
const profileFormChanged = computed(() => {
|
||||
return profileForm.nickname !== profileBaseline.nickname
|
||||
|| profileForm.avatar !== profileBaseline.avatar
|
||||
|| profileForm.contactPhone !== profileBaseline.contactPhone
|
||||
|| profileForm.wechatId !== profileBaseline.wechatId
|
||||
|| profileForm.signature !== profileBaseline.signature
|
||||
})
|
||||
|
||||
const go = async (item: ProfileMenu): Promise<void> => {
|
||||
if (item.action === 'editProfile') {
|
||||
openEditProfile()
|
||||
|
||||
Reference in New Issue
Block a user