|
@@ -1,6 +1,6 @@
|
|
import { RootState } from "@/store";
|
|
import { RootState } from "@/store";
|
|
import { GoodsTableSearch } from "@/types";
|
|
import { GoodsTableSearch } from "@/types";
|
|
-import { Button, Form, Input, message, Popconfirm, Radio, Select } from "antd";
|
|
|
|
|
|
+import { Button, Form, Input, Popconfirm, Radio, Select } from "antd";
|
|
import TextArea from "antd/es/input/TextArea";
|
|
import TextArea from "antd/es/input/TextArea";
|
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
import {
|
|
import {
|
|
@@ -18,6 +18,7 @@ import {
|
|
goodsUploadAPI,
|
|
goodsUploadAPI,
|
|
} from "@/store/action/goods";
|
|
} from "@/store/action/goods";
|
|
import { baseURL } from "@/utils/http";
|
|
import { baseURL } from "@/utils/http";
|
|
|
|
+import { MessageFu } from "@/utils/message";
|
|
|
|
|
|
// 上传附件的进度条
|
|
// 上传附件的进度条
|
|
const UpAsyncLodingDom: any = document.querySelector("#UpAsyncLoding");
|
|
const UpAsyncLodingDom: any = document.querySelector("#UpAsyncLoding");
|
|
@@ -61,7 +62,7 @@ function GoodsAdd({ id, closePage, upTableList, addTableList }: Props) {
|
|
|
|
|
|
// 没有通过校验
|
|
// 没有通过校验
|
|
const onFinishFailed = useCallback(() => {
|
|
const onFinishFailed = useCallback(() => {
|
|
- // return message.warning("有表单不符号规则!");
|
|
|
|
|
|
+ // return MessageFu.warning("有表单不符号规则!");
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -104,15 +105,15 @@ function GoodsAdd({ id, closePage, upTableList, addTableList }: Props) {
|
|
// 通过校验点击确定
|
|
// 通过校验点击确定
|
|
const onFinish = useCallback(
|
|
const onFinish = useCallback(
|
|
async (values: GoodsTableSearch) => {
|
|
async (values: GoodsTableSearch) => {
|
|
- if (cover === "") return message.warning("请上传封面图!");
|
|
|
|
|
|
+ if (cover === "") return MessageFu.warning("请上传封面图!");
|
|
if (type === "model" && modelSrc === "")
|
|
if (type === "model" && modelSrc === "")
|
|
- return message.warning("请输入模型的链接地址!");
|
|
|
|
|
|
+ return MessageFu.warning("请输入模型的链接地址!");
|
|
if (type === "img" && imgFile.filePath === "")
|
|
if (type === "img" && imgFile.filePath === "")
|
|
- return message.warning("请上传图片附件!");
|
|
|
|
|
|
+ return MessageFu.warning("请上传图片附件!");
|
|
if (type === "audio" && audioFile.filePath === "")
|
|
if (type === "audio" && audioFile.filePath === "")
|
|
- return message.warning("请上传音频附件!");
|
|
|
|
|
|
+ return MessageFu.warning("请上传音频附件!");
|
|
if (type === "video" && videoFile.filePath === "")
|
|
if (type === "video" && videoFile.filePath === "")
|
|
- return message.warning("请上传视频附件!");
|
|
|
|
|
|
+ return MessageFu.warning("请上传视频附件!");
|
|
|
|
|
|
let fileArr = { fileName: "", filePath: "" };
|
|
let fileArr = { fileName: "", filePath: "" };
|
|
|
|
|
|
@@ -133,7 +134,7 @@ function GoodsAdd({ id, closePage, upTableList, addTableList }: Props) {
|
|
const res: any = await goodsSaveAPI(obj);
|
|
const res: any = await goodsSaveAPI(obj);
|
|
|
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
- message.success(id ? "编辑成功!" : "新增成功!");
|
|
|
|
|
|
+ MessageFu.success(id ? "编辑成功!" : "新增成功!");
|
|
if (id) upTableList();
|
|
if (id) upTableList();
|
|
else addTableList();
|
|
else addTableList();
|
|
|
|
|
|
@@ -166,12 +167,12 @@ function GoodsAdd({ id, closePage, upTableList, addTableList }: Props) {
|
|
const type = ["image/jpeg", "image/png"];
|
|
const type = ["image/jpeg", "image/png"];
|
|
if (!type.includes(filesInfo.type)) {
|
|
if (!type.includes(filesInfo.type)) {
|
|
e.target.value = "";
|
|
e.target.value = "";
|
|
- return message.warning("只支持jpg、png格式!");
|
|
|
|
|
|
+ return MessageFu.warning("只支持jpg、png格式!");
|
|
}
|
|
}
|
|
// 校验大小
|
|
// 校验大小
|
|
if (filesInfo.size > 10 * 1024 * 1024) {
|
|
if (filesInfo.size > 10 * 1024 * 1024) {
|
|
e.target.value = "";
|
|
e.target.value = "";
|
|
- return message.warning("最大支持10M!");
|
|
|
|
|
|
+ return MessageFu.warning("最大支持10M!");
|
|
}
|
|
}
|
|
// 创建FormData对象
|
|
// 创建FormData对象
|
|
const fd = new FormData();
|
|
const fd = new FormData();
|
|
@@ -184,7 +185,7 @@ function GoodsAdd({ id, closePage, upTableList, addTableList }: Props) {
|
|
|
|
|
|
const res: any = await goodsUploadAPI(fd);
|
|
const res: any = await goodsUploadAPI(fd);
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
- message.success("上传成功!");
|
|
|
|
|
|
+ MessageFu.success("上传成功!");
|
|
setCover(res.data.filePath);
|
|
setCover(res.data.filePath);
|
|
}
|
|
}
|
|
UpAsyncLodingDom.style.opacity = 0;
|
|
UpAsyncLodingDom.style.opacity = 0;
|
|
@@ -219,12 +220,12 @@ function GoodsAdd({ id, closePage, upTableList, addTableList }: Props) {
|
|
// 校验格式
|
|
// 校验格式
|
|
if (!anType.includes(filesInfo.type)) {
|
|
if (!anType.includes(filesInfo.type)) {
|
|
e.target.value = "";
|
|
e.target.value = "";
|
|
- return message.warning(anTit1);
|
|
|
|
|
|
+ return MessageFu.warning(anTit1);
|
|
}
|
|
}
|
|
// 校验大小
|
|
// 校验大小
|
|
if (filesInfo.size > anSize) {
|
|
if (filesInfo.size > anSize) {
|
|
e.target.value = "";
|
|
e.target.value = "";
|
|
- return message.warning(anTit2);
|
|
|
|
|
|
+ return MessageFu.warning(anTit2);
|
|
}
|
|
}
|
|
// 创建FormData对象
|
|
// 创建FormData对象
|
|
const fd = new FormData();
|
|
const fd = new FormData();
|
|
@@ -236,7 +237,7 @@ function GoodsAdd({ id, closePage, upTableList, addTableList }: Props) {
|
|
|
|
|
|
const res: any = await goodsUploadAPI(fd);
|
|
const res: any = await goodsUploadAPI(fd);
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
- message.success("上传成功!");
|
|
|
|
|
|
+ MessageFu.success("上传成功!");
|
|
if (type === "img") setImgFile(res.data);
|
|
if (type === "img") setImgFile(res.data);
|
|
else if (type === "audio") setAudioFile(res.data);
|
|
else if (type === "audio") setAudioFile(res.data);
|
|
else if (type === "video") setVideoFile(res.data);
|
|
else if (type === "video") setVideoFile(res.data);
|