(component): 优化 upload 组件代码

This commit is contained in:
就眠儀式 2022-10-16 10:35:04 +08:00
parent e181ba7ad2
commit e994893bfc
3 changed files with 6 additions and 11 deletions

View File

@ -1,7 +1,7 @@
<script lang="ts">
export default {
name: "TableRow",
}
};
</script>
<script lang="ts" setup>

View File

@ -810,7 +810,10 @@ onBeforeUnmount(() => {
</colgroup>
<tbody>
<!-- 渲染 -->
<template v-for="(children, index) in tableDataSource" :key="index">
<template
v-for="(children, index) in tableDataSource"
:key="index"
>
<table-row
:id="id"
:index="index"

View File

@ -291,19 +291,11 @@ const uploadChange = (e: any) => {
return;
}
if (props.size && props.size != 0) {
let _cache = [];
for (let i = 0; i < _files.length; i++) {
let _file = _files[i];
let _size = _file.size;
if (_size > props.size * 1024) {
_cache.push(_file);
}
}
if (_cache && _cache.length > 0) {
for (let i = 0; i < _cache.length; i++) {
let _sizeErrorFile = _cache[i];
let errorMsg = `文件 ${_sizeErrorFile.name} ${sizeErrorMsg},文件最大不可超过${props.size}KB`;
errorF(errorMsg);
errorF(`文件 ${_file.name} ${sizeErrorMsg},文件最大不可超过${props.size}KB`);
return;
}
}