fix: 🐛 修复因接口调整而影响的调用页面的问题

This commit is contained in:
hxr
2024-05-04 13:15:06 +08:00
parent 088bc5e48f
commit 425841ad45
6 changed files with 13 additions and 14 deletions

View File

@@ -78,7 +78,7 @@ watch(
*/ */
async function handleUpload(options: UploadRequestOptions): Promise<any> { async function handleUpload(options: UploadRequestOptions): Promise<any> {
// 上传API调用 // 上传API调用
const { data: fileInfo } = await FileAPI.upload(options.file); const data = await FileAPI.upload(options.file);
// 上传成功需手动替换文件路径为远程URL否则图片地址为预览地址 blob:http:// // 上传成功需手动替换文件路径为远程URL否则图片地址为预览地址 blob:http://
const fileIndex = fileList.value.findIndex( const fileIndex = fileList.value.findIndex(
@@ -86,8 +86,8 @@ async function handleUpload(options: UploadRequestOptions): Promise<any> {
); );
fileList.value.splice(fileIndex, 1, { fileList.value.splice(fileIndex, 1, {
name: fileInfo.name, name: data.name,
url: fileInfo.url, url: data.url,
} as UploadUserFile); } as UploadUserFile);
emit( emit(

View File

@@ -33,8 +33,8 @@ const imgUrl = useVModel(props, "modelValue", emit);
* @param options * @param options
*/ */
async function uploadFile(options: UploadRequestOptions): Promise<any> { async function uploadFile(options: UploadRequestOptions): Promise<any> {
const { data: fileInfo } = await FileAPI.update(options.file); const data = await FileAPI.upload(options.file);
imgUrl.value = fileInfo.url; imgUrl.value = data.url;
} }
/** /**

View File

@@ -23,7 +23,7 @@
import { Editor, Toolbar } from "@wangeditor/editor-for-vue"; import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
// API 引用 // API 引用
import { uploadFileApi } from "@/api/file"; import FileAPI from "@/api/file";
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
@@ -46,9 +46,8 @@ const editorConfig = ref({
uploadImage: { uploadImage: {
// 自定义图片上传 // 自定义图片上传
async customUpload(file: any, insertFn: any) { async customUpload(file: any, insertFn: any) {
uploadFileApi(file).then((response) => { FileAPI.upload(file).then((data) => {
const url = response.data.url; insertFn(data.url);
insertFn(url);
}); });
}, },
}, },

View File

@@ -65,8 +65,8 @@ const {
// 编辑 // 编辑
async function handleEditClick(row: IObject) { async function handleEditClick(row: IObject) {
// 根据id获取数据进行填充 // 根据id获取数据进行填充
const response = await UserAPI.getFormData(row.id); const data = await UserAPI.getFormData(row.id);
editModalRef.value?.setModalVisible(response.data); editModalRef.value?.setModalVisible(data);
} }
// 其他工具栏 // 其他工具栏
function handleToolbarClick(name: string) { function handleToolbarClick(name: string) {

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { uploadFileApi } from "@/api/file"; import FileAPI from "@/api/file";
const imgUrl = ref(""); const imgUrl = ref("");
const canvas = ref(); const canvas = ref();
@@ -68,7 +68,7 @@ const handleToFile = async () => {
const file = dataURLtoFile(canvas.value.toDataURL(), "签名.png"); const file = dataURLtoFile(canvas.value.toDataURL(), "签名.png");
if (!file) return; if (!file) return;
const { data } = await uploadFileApi(file); const data = await FileAPI.upload(file);
handleClearSign(); handleClearSign();
imgUrl.value = data.url; imgUrl.value = data.url;
}; };

View File

@@ -254,7 +254,7 @@ function handleSubmit() {
}) })
.finally(() => (loading.value = false)); .finally(() => (loading.value = false));
} else { } else {
DeptAPI.update(formData) DeptAPI.add(formData)
.then(() => { .then(() => {
ElMessage.success("新增成功"); ElMessage.success("新增成功");
closeDialog(); closeDialog();