联系单模板

This commit is contained in:
Teo
2025-07-03 20:52:22 +08:00
parent d698245da5
commit f9d1f4144f
10 changed files with 839 additions and 143 deletions

View File

@ -17,6 +17,7 @@
:accept="accept"
:drag="isDarg"
:data="data"
:auto-upload="autoUpload"
>
<slot>
<div>
@ -80,7 +81,6 @@
import { propTypes } from '@/utils/propTypes';
import { delOss, listByIds } from '@/api/system/oss';
import { globalHeaders } from '@/utils/request';
const props = defineProps({
modelValue: {
type: [String, Object, Array],
@ -102,6 +102,8 @@ const props = defineProps({
uploadUrl: propTypes.string.def('/resource/oss/upload'),
//可拖拽上传
isDarg: propTypes.bool.def(false),
// 是否自动上传
autoUpload: propTypes.bool.def(true),
// 其他参数
data: propTypes.object.def({}),
onUploadSuccess: {
@ -118,7 +120,6 @@ const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const emit = defineEmits(['update:modelValue']);
const number = ref(0);
const uploadList = ref<any[]>([]);
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadFileUrl = ref(baseUrl + props.uploadUrl); // 上传文件服务器地址
const headers = ref(globalHeaders());
@ -216,6 +217,8 @@ interface UploadFileWithOssId extends UploadFile {
}
const handleUploadSuccess = (res: any, file: UploadFileWithOssId) => {
console.log(props.data);
if (res.code === 200) {
if (res.data) {
uploadList.value.push({
@ -239,8 +242,6 @@ const handleUploadSuccess = (res: any, file: UploadFileWithOssId) => {
// 删除文件
const handleDelete = async (index: string | number, type?: string) => {
console.log('🚀 ~ handleDelete ~ index:', index);
await proxy?.$modal.confirm('是否确认删除此文件?').finally();
if (type === 'ossId') {
delOss(index);
@ -263,7 +264,6 @@ const uploadedSuccessfully = () => {
proxy?.$modal.msgSuccess('导入成功');
return;
}
console.log(number.value, uploadList.value);
if (number.value > 0 && uploadList.value.length === number.value) {
fileList.value = fileList.value.filter((f) => f.url !== undefined).concat(uploadList.value);
@ -297,6 +297,14 @@ const listToString = (list: any[], separator?: string) => {
});
return strs != '' ? strs.substring(0, strs.length - 1) : '';
};
const submitUpload = () => {
fileUploadRef.value!.submit();
};
defineExpose({
submitUpload
});
</script>
<style scoped lang="scss">