fix submit button position
This commit is contained in:
@@ -147,18 +147,6 @@
|
||||
accept="image/*"
|
||||
@change="handlePhotoSelected"
|
||||
>
|
||||
<t-button
|
||||
theme="primary"
|
||||
class="save"
|
||||
:disabled="!canSubmit"
|
||||
:loading="isSubmitting"
|
||||
@click="doSubmit"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="check" />
|
||||
</template>
|
||||
保存
|
||||
</t-button>
|
||||
<customer-selector
|
||||
v-model="introducerCustomerId"
|
||||
v-model:visible="selectorVisible"
|
||||
@@ -203,6 +191,7 @@ import PhotoScroller from "@/components/PhotoScroller.vue";
|
||||
import TagSelector from "@/components/TagSelector.vue";
|
||||
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import { useSettingStore } from "@/store/settingStore";
|
||||
import type { BodyAreaValue, Customer, CustomerAttachmentType, EditableCustomerPhoto } from "@/types/Customer";
|
||||
import type { Tag } from "@/types/Tag";
|
||||
@@ -222,8 +211,10 @@ const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const settingStore = useSettingStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const navBarStore = useNavBarStore();
|
||||
const isCreateMode = computed(() => route.name === "CustomerCreate");
|
||||
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.customer.create : permissionCodes.customer.update);
|
||||
const hasCustomerDeletePermission = computed(() => userStore.hasPermissions(permissionCodes.customer.delete));
|
||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||
|
||||
let latestDecodedText = "";
|
||||
@@ -457,6 +448,14 @@ async function loadDetail() {
|
||||
}
|
||||
}
|
||||
onMounted(loadDetail);
|
||||
|
||||
onMounted(() => {
|
||||
navBarStore.clearRight();
|
||||
if (userStore.hasPermissions(savePermissionCode.value)) {
|
||||
navBarStore.setRightText("保存", "var(--td-brand-color)", doSubmit);
|
||||
}
|
||||
});
|
||||
|
||||
watch(() => route.fullPath, loadDetail);
|
||||
|
||||
// ---------- 年龄 ----------
|
||||
@@ -524,6 +523,23 @@ function normalizeAttachmentType(attachType?: string): CustomerAttachmentType {
|
||||
return "PHOTO";
|
||||
}
|
||||
|
||||
function validateCustomerPhotoList(): boolean {
|
||||
if (hasCustomerDeletePermission.value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const attachTypeSet = new Set(photoItemList.value.map(item => item.attachType));
|
||||
if (!attachTypeSet.has("PHOTO")) {
|
||||
Toast.warning("请上传客户照片");
|
||||
return false;
|
||||
}
|
||||
if (!attachTypeSet.has("POINT_CARD")) {
|
||||
Toast.warning("请上传积分卡照片");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function handlePhotoSelected(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
@@ -552,10 +568,20 @@ async function handlePhotoSelected(event: Event): Promise<void> {
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
async function doSubmit(): Promise<void> {
|
||||
if (!formData.storeId) {
|
||||
if (isSubmitting.value) {
|
||||
return;
|
||||
}
|
||||
if (!canSubmit.value) {
|
||||
if (!formData.name?.trim()) {
|
||||
Toast.warning("请填写姓名");
|
||||
return;
|
||||
}
|
||||
Toast.warning("请选择门店");
|
||||
return;
|
||||
}
|
||||
if (!validateCustomerPhotoList()) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting.value = true;
|
||||
try {
|
||||
@@ -594,6 +620,10 @@ async function doSubmit(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
navBarStore.clearRight();
|
||||
});
|
||||
|
||||
function buildAttachmentList(): Attachment[] {
|
||||
return photoItemList.value.flatMap(item => {
|
||||
if (item.attachment) {
|
||||
@@ -660,12 +690,6 @@ function buildAttachmentList(): Attachment[] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.save {
|
||||
left: 1rem;
|
||||
right: 1rem;
|
||||
bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
|
||||
position: fixed;
|
||||
}
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
|
||||
@@ -96,17 +96,6 @@
|
||||
</template>
|
||||
导出
|
||||
</t-button>
|
||||
<t-button
|
||||
v-can="permissionCodes.customer.create"
|
||||
theme="primary"
|
||||
class="create"
|
||||
@click="toCreate"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="add" />
|
||||
</template>
|
||||
添加
|
||||
</t-button>
|
||||
</div>
|
||||
<tag-selector
|
||||
v-model="selectedTagIdList"
|
||||
@@ -124,6 +113,7 @@ import CustomerAPI from "@/api/CustomerAPI";
|
||||
import GenderIcon from "@/components/GenderIcon.vue";
|
||||
import TagSelector from "@/components/TagSelector.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
import type { Tag } from "@/types/Tag";
|
||||
import { getCustomerPhotoURL } from "@/utils/customer";
|
||||
@@ -136,6 +126,7 @@ defineOptions({
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const navBarStore = useNavBarStore();
|
||||
const isRefreshing = ref(false);
|
||||
const isExporting = ref(false);
|
||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||
@@ -239,6 +230,13 @@ async function loadData(): Promise<void> {
|
||||
|
||||
onMounted(loadData);
|
||||
|
||||
onMounted(() => {
|
||||
navBarStore.clearRight();
|
||||
if (userStore.hasPermissions(permissionCodes.customer.create)) {
|
||||
navBarStore.setRightText("添加", "var(--td-brand-color)", toCreate);
|
||||
}
|
||||
});
|
||||
|
||||
watch(keyword, async () => {
|
||||
window.clearTimeout(keywordTimer);
|
||||
keywordTimer = window.setTimeout(async () => {
|
||||
@@ -247,6 +245,7 @@ watch(keyword, async () => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
navBarStore.clearRight();
|
||||
window.clearTimeout(keywordTimer);
|
||||
});
|
||||
|
||||
@@ -371,9 +370,6 @@ async function doExport(): Promise<void> {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.create {
|
||||
flex: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user