修复上传问题

This commit is contained in:
橙子
2022-10-16 15:54:49 +08:00
parent 95c506c638
commit cf43dc8e70
15 changed files with 86 additions and 26 deletions

View File

@@ -73,8 +73,8 @@ import { ref, onMounted, reactive, toRefs } from "vue";
import { ImagePreview, Toast } from "vant";
import AppCreateTime from "@/components/AppCreateTime.vue";
import AppUserIcon from "@/components/AppUserIcon.vue";
import articleApi from "@/api/articleApi.ts";
import { ArticleEntity } from "@/type/interface/ArticleEntity.ts";
import articleApi from "@/api/articleApi";
import { ArticleEntity } from "@/type/interface/ArticleEntity";
const VanImagePreview = ImagePreview.Component;
const url = `${import.meta.env.VITE_APP_BASE_API}/file/`;
const data = reactive({
@@ -88,7 +88,7 @@ const data = reactive({
});
const { queryParams } = toRefs(data);
const articleList = ref<ArticleEntity[]>([]);
const articleList = ref<any[]>([]);
const totol = ref<Number>(0);
const imageShow = ref(false);
const index = ref(0);
@@ -119,7 +119,7 @@ const onLoad = async () => {
finished.value = true;
} else {
console.log("执行");
articleList.value.push(...(response.data.data as ArticleEntity[]));
articleList.value.push(...(response.data.data));
totol.value = response.data.totol;
queryParams.value.pageNum += 1;
}
@@ -149,7 +149,7 @@ onMounted(() => {
const getList = () => {
articleApi.pageList(queryParams.value).then((response: any) => {
articleList.value.push(...(response.data.data as ArticleEntity[]));
articleList.value.push(...(response.data.data));
totol.value = response.data.totol;
});
};

View File

@@ -90,7 +90,7 @@
</template>
<script setup lang="ts">
import AppGrid from "@/components/AppGrid.vue";
import { AppGridData } from "@/type/class/AppGridData.ts";
import { AppGridData } from "@/type/class/AppGridData";
import { ref } from "vue";
import { Dialog } from "vant";
import useUserStore from "@/store/modules/user";

View File

@@ -39,7 +39,7 @@
<van-divider />
<van-row>
<van-col class="img-col" span="24">
<van-uploader :after-read="afterRead" v-model="fileList" multiple />
<van-uploader accept="image/*" :after-read="afterRead" v-model="fileList" multiple />
</van-col>
</van-row>
</div>
@@ -47,9 +47,9 @@
</template>
<script setup lang="ts">
import { ref, onMounted, reactive, toRefs,watch } from "vue";
import { ArticleEntity } from "@/type/interface/ArticleEntity.ts";
import fileApi from "@/api/fileApi.ts";
import articleApi from "@/api/articleApi.ts";
import { ArticleEntity } from "@/type/interface/ArticleEntity";
import fileApi from "@/api/fileApi";
import articleApi from "@/api/articleApi";
import { Toast } from "vant";
import { useRouter } from 'vue-router'
const router = useRouter();
@@ -58,6 +58,7 @@ const form = reactive<ArticleEntity>({
content: "",
images: [],
isDeleted: false,
createTime:""
});
const isSend=ref(false)
@@ -68,7 +69,6 @@ onMounted(() => {
visible.value = true;
});
const afterRead = (file: any) => {
file.status = "uploading";
file.message = "上传中...";
var formData = new FormData();
@@ -83,12 +83,20 @@ else
file.forEach((f:any) => {
formData.append("file", f.file);
});
Toast({
message: "全部文件正在上传",
position: "bottom",
});
}
fileApi.upload("image", formData)
.then((response: any) => {
images.value.push(...response.data);
file.status = "done";
file.message = "成功";
Toast({
message: "文件上传成功",
position: "bottom",
});
})
};
@@ -118,7 +126,6 @@ watch(()=>form.content,(newValue,oldValue)=>{
{
isSend.value=true
}
console.log(isSend.value?'#FFF':'#111')
})
</script>
<style scoped>