fix(BUG:51):投票文件类型限制上传

This commit is contained in:
wuyx
2022-12-02 17:19:06 +08:00
parent 595fc8af8d
commit cb4423575e

View File

@@ -73,8 +73,8 @@
<span style="margin-right: 3px">基础投票数</span>
</div>
<div class="btnbox">
<a-upload @change="handleChange" :multiple="true" :max-count="1" action="/manageApi/vote/baseVoteupload"
v-model:file-list="fileList">
<a-upload @change="handleChange" :before-upload="beforeUpload" :multiple="true" :max-count="1"
action="/manageApi/vote/baseVoteupload" v-model:file-list="fileList">
<button class="xkbtn">点击上传</button></a-upload>
<div v-if="voteCount > 0"><a-tag color="processing"> <span style="font-size:14px;line-height: 33px;">{{
voteCount
@@ -218,7 +218,23 @@ export default {
};
// 限制文件格式上传
const beforeUpload = (obj) => {
console.log(obj)
}
const handleChange = info => {
console.log(info.file.type, info.file.type.indexOf('sheet'))
if (info.file.type.indexOf('sheet') == -1) {
message.destroy()
message.error("请上传正确的文件格式")
console.log(state.fileList)
state.fileList = []
return
}
let resFileList = [...info.fileList];
@@ -353,7 +369,7 @@ export default {
if (props.edit) {
api
.editVote(obj)
.then(async(res) => {
.then(async (res) => {
console.log("updte======");
await updateToTask(res);
closeDrawer();
@@ -367,7 +383,7 @@ export default {
} else {
api
.createVote(obj)
.then(async(res) => {
.then(async (res) => {
await updateToTask(res);
closeDrawer();
message.destroy();
@@ -401,6 +417,7 @@ export default {
queryStem,
closeStem,
handleChange,
beforeUpload,
log,
};
},