|
@@ -135,7 +135,7 @@
|
|
<el-option :value="1" label="图片" />
|
|
<el-option :value="1" label="图片" />
|
|
</el-select>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="素材文件">
|
|
|
|
|
|
+ <el-form-item label="素材文件" prop="fileList">
|
|
<el-upload
|
|
<el-upload
|
|
ref="uploadRef"
|
|
ref="uploadRef"
|
|
action=""
|
|
action=""
|
|
@@ -144,6 +144,8 @@
|
|
:on-remove="uploadRemove"
|
|
:on-remove="uploadRemove"
|
|
:auto-upload="false"
|
|
:auto-upload="false"
|
|
:limit="1"
|
|
:limit="1"
|
|
|
|
+ :on-exceed="handleExceed"
|
|
|
|
+ :on-preview="handlePreview"
|
|
>
|
|
>
|
|
<template #trigger>
|
|
<template #trigger>
|
|
<el-button type="primary">选择文件</el-button>
|
|
<el-button type="primary">选择文件</el-button>
|
|
@@ -240,6 +242,9 @@ const data = reactive({
|
|
materialType: [
|
|
materialType: [
|
|
{ required: true, message: "素材类型不能为空", trigger: "change" },
|
|
{ required: true, message: "素材类型不能为空", trigger: "change" },
|
|
],
|
|
],
|
|
|
|
+ fileList: [
|
|
|
|
+ { required: true, message: "素材文件不能为空", trigger: "change" },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
libraryType: {
|
|
libraryType: {
|
|
0: "视频",
|
|
0: "视频",
|
|
@@ -324,7 +329,9 @@ function handleUpdate(row) {
|
|
materialId: res.data.materialId,
|
|
materialId: res.data.materialId,
|
|
materialName: res.data.materialName,
|
|
materialName: res.data.materialName,
|
|
materialType: res.data.materialType,
|
|
materialType: res.data.materialType,
|
|
- fileList: [],
|
|
|
|
|
|
+ fileList: res.data.accessory
|
|
|
|
+ ? [{ ...res.data.accessory, name: res.data.accessory.originFileName }]
|
|
|
|
+ : [],
|
|
};
|
|
};
|
|
})
|
|
})
|
|
.finally(() => {
|
|
.finally(() => {
|
|
@@ -342,7 +349,7 @@ function dialogSubmit() {
|
|
formData.append("materialName", materialName);
|
|
formData.append("materialName", materialName);
|
|
formData.append("materialType", materialType);
|
|
formData.append("materialType", materialType);
|
|
fileList.forEach((file) => {
|
|
fileList.forEach((file) => {
|
|
- formData.append("file", file.raw);
|
|
|
|
|
|
+ file.raw && formData.append("file", file.raw || "");
|
|
});
|
|
});
|
|
if (form.value.materialId) {
|
|
if (form.value.materialId) {
|
|
formData.append("materialId", form.value.materialId);
|
|
formData.append("materialId", form.value.materialId);
|
|
@@ -390,6 +397,17 @@ function uploadRemove() {
|
|
form.value.fileList = [];
|
|
form.value.fileList = [];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 文件上传超出限制
|
|
|
|
+function handleExceed() {
|
|
|
|
+ proxy.$modal.msgError("最多上传一个素材文件");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 下载文件
|
|
|
|
+function handlePreview(file) {
|
|
|
|
+ let url = import.meta.env.VITE_APP_BASE_API + file.filePath;
|
|
|
|
+ window.open(url);
|
|
|
|
+}
|
|
|
|
+
|
|
function handlepreview(row) {
|
|
function handlepreview(row) {
|
|
if (!row.url) {
|
|
if (!row.url) {
|
|
proxy.$modal.msgError("视频文件错误,请重新上传视频");
|
|
proxy.$modal.msgError("视频文件错误,请重新上传视频");
|