|
@@ -18,17 +18,19 @@
|
|
|
</template>
|
|
|
<template #file="{ model, field }">
|
|
|
<Upload
|
|
|
+ :key="isAnimation"
|
|
|
style="width: 300px"
|
|
|
- accept=".jpg, .png, .jpeg, .mp4, .wav, .mp3, .shp, .zip"
|
|
|
+ :disabled="!fileFlow.dictId"
|
|
|
+ :accept="!isAnimation?'.jpg, .png, .jpeg, .mp4, .wav, .mp3, .shp, .zip':'.glb, .zip'"
|
|
|
v-model:file-list="fileList"
|
|
|
:beforeUpload="beforeUpload"
|
|
|
@remove="handleRemove"
|
|
|
>
|
|
|
- <a-button> 上传 </a-button>
|
|
|
+ <a-button :disabled="!fileFlow.dictId"> 上传 </a-button>
|
|
|
</Upload>
|
|
|
</template>
|
|
|
</BasicForm>
|
|
|
- <div style="padding: 0 0 0 82px">
|
|
|
+ <div style="padding: 0 0 0 82px" v-if="!isAnimation">
|
|
|
<div style="margin-bottom: 10px"
|
|
|
>支持jpg、png、jpeg、mp4、wav、mp3 、shp格式文件上传。文件大小 ≤ 2G</div
|
|
|
>
|
|
@@ -42,11 +44,25 @@
|
|
|
</div>
|
|
|
<div style="margin-bottom: 10px">
|
|
|
<div>
|
|
|
- 上传 osgb:需使用zip包上传。包含 Data 文件夹、xml 文件,包内不得包含文件夹,文件名不得使用中文。如图:</div
|
|
|
+ 上传 osgb:需使用zip包上传。包含 Data 文件夹、xml
|
|
|
+ 文件,包内不得包含文件夹,文件名不得使用中文。如图:</div
|
|
|
>
|
|
|
<img style="width: 150px" :src="osgb" alt="" />
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div v-else style="padding: 0 0 0 82px">
|
|
|
+ <div style="margin-bottom: 10px"
|
|
|
+ >支持obj、glb格式文件上传。文件大小 ≤ 5MB</div
|
|
|
+ >
|
|
|
+ <!-- <span>注意:模型需使用zip包上传。包含贴图、模型、mtl文件,包内不得包含文件夹。</span> -->
|
|
|
+ <div style="margin-bottom: 10px">
|
|
|
+ <div>
|
|
|
+ 上传
|
|
|
+ obj:需使用zip包上传。包含贴图、模型、mtl文件,包内不得包含文件夹,文件名不得使用中文。如图:</div
|
|
|
+ >
|
|
|
+ <img style="width: 150px" :src="obj" alt="" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</BasicModal>
|
|
|
</template>
|
|
@@ -71,12 +87,14 @@
|
|
|
emits: ['update', 'register'],
|
|
|
setup(props, { emit }) {
|
|
|
const modelRef = ref({});
|
|
|
+ const isAnimation = ref(false)
|
|
|
const fileList = ref<UploadProps['fileList']>([]);
|
|
|
const loading = ref(false);
|
|
|
const fileFlow = reactive({
|
|
|
file: null,
|
|
|
title: '上传',
|
|
|
complete: 0,
|
|
|
+ dictId: null,
|
|
|
});
|
|
|
const { createMessage } = useMessage();
|
|
|
const schemas: FormSchema[] = [
|
|
@@ -123,6 +141,11 @@
|
|
|
params: {
|
|
|
type: 1,
|
|
|
},
|
|
|
+ onChange: (val,text) => {
|
|
|
+ fileFlow.dictId = val
|
|
|
+ fileList.value = [];
|
|
|
+ isAnimation.value = text.useType == "animation"
|
|
|
+ },
|
|
|
},
|
|
|
itemProps: {
|
|
|
autoLink: false,
|
|
@@ -151,14 +174,14 @@
|
|
|
function onDataReceive(data) {
|
|
|
modelRef.value = data;
|
|
|
resetFields();
|
|
|
- fileList.value = []
|
|
|
+ fileList.value = [];
|
|
|
setFieldsValue({
|
|
|
type: data.sceneName,
|
|
|
});
|
|
|
}
|
|
|
const handleSubmit = debounce(async () => {
|
|
|
let file = fileList.value[0];
|
|
|
- if(!file){
|
|
|
+ if (!file) {
|
|
|
createMessage.warning('请上传文件');
|
|
|
return;
|
|
|
}
|
|
@@ -188,7 +211,7 @@
|
|
|
loading.value = false;
|
|
|
console.log('not passing', error);
|
|
|
}
|
|
|
- },300);
|
|
|
+ }, 300);
|
|
|
function handleVisibleChange(v) {
|
|
|
// console.log(v);
|
|
|
// v && props.userData && nextTick(() => onDataReceive(props.userData));
|
|
@@ -206,17 +229,31 @@
|
|
|
const isExcel = ['jpg', 'jpg', 'png', 'jpeg', 'mp4', 'wav', 'mp3', 'shp', 'zip'].includes(
|
|
|
filetype,
|
|
|
); // 调用上面代码
|
|
|
- if (!isExcel) {
|
|
|
+ const isdonghua = ['glb', 'zip'].includes(
|
|
|
+ filetype,
|
|
|
+ );
|
|
|
+ if (!isExcel && isAnimation.value) {
|
|
|
+ createMessage.error('支持obj、glb格式文件上传');
|
|
|
+ fileList.value = [];
|
|
|
+ return Upload.LIST_IGNORE;
|
|
|
+ }
|
|
|
+ if (!isdonghua && !isAnimation.value) {
|
|
|
createMessage.error('支持jpg、png、jpeg、mp4、wav、mp3 、shp、zip格式文件上传');
|
|
|
fileList.value = [];
|
|
|
return Upload.LIST_IGNORE;
|
|
|
}
|
|
|
const isLt10M = file.size / 1024 / 1024 < 2000;
|
|
|
- if (!isLt10M) {
|
|
|
+ const isLt5M = file.size / 1024 / 1024 < 5;
|
|
|
+ if (!isLt10M && !isAnimation.value) {
|
|
|
fileList.value = [];
|
|
|
createMessage.error('上传文件不能超过 2G!');
|
|
|
return Upload.LIST_IGNORE;
|
|
|
}
|
|
|
+ if (!isLt5M && isAnimation.value) {
|
|
|
+ fileList.value = [];
|
|
|
+ createMessage.error('上传文件不能超过 5MB!');
|
|
|
+ return Upload.LIST_IGNORE;
|
|
|
+ }
|
|
|
fileList.value = [file];
|
|
|
return false;
|
|
|
};
|
|
@@ -237,6 +274,7 @@
|
|
|
fileList,
|
|
|
handleRemove,
|
|
|
beforeUpload,
|
|
|
+ isAnimation,
|
|
|
};
|
|
|
},
|
|
|
});
|