use Message instead of Toast
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Toast } from "tdesign-mobile-vue";
|
||||
import { Message } from "@/utils/message";
|
||||
import CustomerAPI from "@/api/CustomerAPI";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
import EventRecordAPI from "@/api/EventRecordAPI";
|
||||
@@ -143,7 +143,7 @@ async function selectEvent(eventId?: string): Promise<void> {
|
||||
Storage.setString(EventItemStorageKey, selectedEventId);
|
||||
eventSelectorVisible.value = false;
|
||||
await loadSourceValueRule();
|
||||
Toast.success("登记事件已切换");
|
||||
Message.success("登记事件已切换");
|
||||
}
|
||||
|
||||
onMounted(loadActions);
|
||||
@@ -251,16 +251,16 @@ async function doSubmit(): Promise<void> {
|
||||
const pointValue = resolveSourceValue();
|
||||
const numberValue = resolveNumberValue();
|
||||
if (showNumberValueInput.value && numberValueText.value.trim() && numberValue === undefined) {
|
||||
Toast.warning("事件数值格式不正确,请检查单位和小数位");
|
||||
Message.warning("事件数值格式不正确,请检查单位和小数位");
|
||||
return;
|
||||
}
|
||||
if (selectedEvent.value?.requireValue && numberValue === undefined) {
|
||||
Toast.warning("请填写事件数值");
|
||||
Message.warning("请填写事件数值");
|
||||
return;
|
||||
}
|
||||
const range = sourceValueConfig.value?.range;
|
||||
if (showSourceValueInput.value && (!pointValue || !range || Math.abs(pointValue) < range[0] || range[1] < Math.abs(pointValue))) {
|
||||
Toast.warning(`积分数量必须是 ${range?.[0] || 1}-${range?.[1] || 0} 的正整数`);
|
||||
Message.warning(`积分数量必须是 ${range?.[0] || 1}-${range?.[1] || 0} 的正整数`);
|
||||
return;
|
||||
}
|
||||
submitting.value = true;
|
||||
|
||||
Reference in New Issue
Block a user