use Message instead of Toast

This commit is contained in:
Timi
2026-08-22 01:08:23 +08:00
parent 94c17e6d81
commit e2af521996
46 changed files with 291 additions and 289 deletions
+12 -20
View File
@@ -140,7 +140,7 @@
<script setup lang="ts">
import { AttachmentAPI, Toolkit, useUserStore, type Attachment } from "timi-web";
import type { TdInputProps } from "tdesign-mobile-vue";
import { Toast } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import CustomerAPI from "@/api/CustomerAPI";
import EventAPI from "@/api/EventAPI";
import CodeScanner from "@/components/CodeScanner.vue";
@@ -227,18 +227,18 @@ function validateNumberValueList(): boolean {
const valueText = numberValueTextMap[eventId] || "";
if (event.valueType !== "NUMBER") {
if (valueText.trim()) {
showToast(`${event.name || "当前事件"}不能提交数值`, "warning");
Message.warning(`${event.name || "当前事件"}不能提交数值`);
return false;
}
continue;
}
const numberValue = resolveNumberValue(eventId);
if (valueText.trim() && numberValue === undefined) {
showToast(`${event.name || "当前事件"}数值格式不正确,请检查单位和小数位`, "warning");
Message.warning(`${event.name || "当前事件"}数值格式不正确,请检查单位和小数位`);
return false;
}
if (event.requireValue && numberValue === undefined) {
showToast(`请填写${event.name || "当前事件"}数值`, "warning");
Message.warning(`请填写${event.name || "当前事件"}数值`);
return false;
}
}
@@ -549,11 +549,11 @@ function validateCustomerPhotoList(): boolean {
const attachTypeSet = new Set(customerPhotoItemList.value.map(item => item.attachType));
if (!attachTypeSet.has("PHOTO")) {
showToast("请上传客户照片", "warning");
Message.warning("请上传客户照片");
return false;
}
if (!attachTypeSet.has("POINT_CARD")) {
showToast("请上传积分卡照片", "warning");
Message.warning("请上传积分卡照片");
return false;
}
return true;
@@ -570,7 +570,7 @@ async function handleCustomerPhotoSelected(event: Event): Promise<void> {
const compressedFile = await compressUploadImage(file);
const [tempFile] = await AttachmentAPI.upload(compressedFile);
if (!tempFile?.id) {
showToast("客户照片上传失败", "warning");
Message.warning("客户照片上传失败");
return;
}
customerPhotoItemList.value.push({
@@ -635,7 +635,7 @@ async function saveRecord(): Promise<void> {
return;
}
if (customerPhotoUploading.value || recordPhotoUploading.value) {
showToast("照片正在上传,请稍候", "warning");
Message.warning("照片正在上传,请稍候");
return;
}
const customerCode = validateForm();
@@ -674,7 +674,7 @@ async function saveRecord(): Promise<void> {
await EventRecordAPI.createWithCustomer(customer);
resetFormAfterSubmit();
await settingStore.playRegisterSuccessSound();
showToast("登记已提交");
Message.success("登记已提交");
await router.replace("/customers");
} finally {
saving.value = false;
@@ -724,11 +724,11 @@ function buildCustomerAttachmentList(): Attachment[] {
function validateForm(): string {
const customerCode = (currentCode.value || scanCode.value).trim();
if (!customerCode) {
showToast("请先输入或扫码客户编码", "warning");
Message.warning("请先输入或扫码客户编码");
return "";
}
if (!customerName.value.trim()) {
showToast("请填写客户姓名", "warning");
Message.warning("请填写客户姓名");
return "";
}
if (!validateCustomerPhotoList()) {
@@ -741,21 +741,13 @@ function validateForm(): string {
const pointValue = resolveSourceValue();
const range = sourceValueConfig.value?.range;
if (!pointValue || !range || Math.abs(pointValue) < range[0] || range[1] < Math.abs(pointValue)) {
showToast(`积分数量必须是 ${range?.[0] || 1}-${range?.[1] || 0} 的正整数`, "warning");
Message.warning(`积分数量必须是 ${range?.[0] || 1}-${range?.[1] || 0} 的正整数`);
return "";
}
}
return customerCode;
}
function showToast(message: string, theme: "success" | "warning" = "success"): void {
Toast({
theme,
direction: "row",
message
});
}
// ---------- 初始化 ----------
onMounted(async () => {