|
@ -1,81 +1,83 @@ |
|
|
<template> |
|
|
<template> |
|
|
<el-dialog :title="title" width="50%" :before-close="handleClose" > |
|
|
|
|
|
<input |
|
|
|
|
|
type="file" |
|
|
|
|
|
accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, xls, xlsx" |
|
|
|
|
|
@change="previewUpload" |
|
|
|
|
|
> |
|
|
|
|
|
<el-button |
|
|
|
|
|
type="primary" |
|
|
|
|
|
:loading="uploadLoading" |
|
|
|
|
|
icon="el-icon-upload" |
|
|
|
|
|
size="mini" |
|
|
|
|
|
@click="uploadEvent" |
|
|
|
|
|
>上传</el-button> |
|
|
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
<el-dialog model-value :title="title" width="50%" :before-close="handleClose"> |
|
|
|
|
|
<input |
|
|
|
|
|
type="file" |
|
|
|
|
|
accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, xls, xlsx" |
|
|
|
|
|
@change="previewUpload" |
|
|
|
|
|
/> |
|
|
|
|
|
<el-button |
|
|
|
|
|
type="primary" |
|
|
|
|
|
:loading="uploadLoading" |
|
|
|
|
|
icon="el-icon-upload" |
|
|
|
|
|
size="mini" |
|
|
|
|
|
@click="uploadEvent" |
|
|
|
|
|
>上传</el-button |
|
|
|
|
|
> |
|
|
|
|
|
</el-dialog> |
|
|
</template> |
|
|
</template> |
|
|
<script> |
|
|
<script> |
|
|
import { importArtResource } from "@/server/factoryModel/materialResourceMaintenance/artStockResource"; |
|
|
import { importArtResource } from "@/server/factoryModel/materialResourceMaintenance/artStockResource"; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'upload', |
|
|
|
|
|
emits:["editCallBack"], |
|
|
|
|
|
props:{ |
|
|
|
|
|
showUploadDailog : { |
|
|
|
|
|
|
|
|
name: "upload", |
|
|
|
|
|
emits: ["editCallBack"], |
|
|
|
|
|
props: { |
|
|
|
|
|
importDialogVisible: { |
|
|
type: Boolean, |
|
|
type: Boolean, |
|
|
default: () => { |
|
|
default: () => { |
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
title: '导入', // 弹框标题 |
|
|
|
|
|
uploadLoading: false, |
|
|
|
|
|
excel: '', |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
created () { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
title: "导入", // 弹框标题 |
|
|
|
|
|
uploadLoading: false, |
|
|
|
|
|
excel: "", |
|
|
|
|
|
}; |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
|
|
|
handleClose(done) { // 取消按钮 |
|
|
|
|
|
done(); |
|
|
|
|
|
}, |
|
|
|
|
|
// 上传文件预览 |
|
|
|
|
|
|
|
|
created() {}, |
|
|
|
|
|
methods: { |
|
|
|
|
|
handleClose(done) { |
|
|
|
|
|
// 取消按钮 |
|
|
|
|
|
done(); |
|
|
|
|
|
}, |
|
|
|
|
|
// 上传文件预览 |
|
|
previewUpload(file) { |
|
|
previewUpload(file) { |
|
|
this.excle = file.target.files[0] |
|
|
|
|
|
|
|
|
this.excle = file.target.files[0]; |
|
|
}, |
|
|
}, |
|
|
// 上传文件 |
|
|
// 上传文件 |
|
|
uploadEvent() { |
|
|
uploadEvent() { |
|
|
this.uploadLoading = true |
|
|
|
|
|
if (this.excle === null || this.excle === '' || this.excle === undefined) { |
|
|
|
|
|
|
|
|
this.uploadLoading = true; |
|
|
|
|
|
if (this.excle === null || this.excle === "" || this.excle === undefined) { |
|
|
this.$message({ |
|
|
this.$message({ |
|
|
showClose: true, |
|
|
showClose: true, |
|
|
duration: 2000, |
|
|
duration: 2000, |
|
|
message: '请选择文件', |
|
|
|
|
|
type: 'error' |
|
|
|
|
|
}) |
|
|
|
|
|
this.uploadLoading = false |
|
|
|
|
|
|
|
|
message: "请选择文件", |
|
|
|
|
|
type: "error", |
|
|
|
|
|
}); |
|
|
|
|
|
this.uploadLoading = false; |
|
|
} else { |
|
|
} else { |
|
|
const uploadData = new FormData() |
|
|
|
|
|
uploadData.append('upload', this.excle) |
|
|
|
|
|
importArtResource(uploadData).then(res => { |
|
|
|
|
|
this.uploadLoading = false |
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
showClose: true, |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
message: '导入成功', |
|
|
|
|
|
type: 'success' |
|
|
|
|
|
}) |
|
|
|
|
|
this.$emit('editCallBack', res.data) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch((res) => { |
|
|
|
|
|
this.uploadLoading = false |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const uploadData = new FormData(); |
|
|
|
|
|
uploadData.append("upload", this.excle); |
|
|
|
|
|
importArtResource(uploadData) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
this.uploadLoading = false; |
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
showClose: true, |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
message: "导入成功", |
|
|
|
|
|
type: "success", |
|
|
|
|
|
}); |
|
|
|
|
|
this.$emit("editCallBack", res.data); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((res) => { |
|
|
|
|
|
this.uploadLoading = false; |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
</script> |