看板时间调整,抛光一次合格批量删除优化,导入文件创建(未完成)

This commit is contained in:
2024-08-27 09:15:34 +08:00
parent f575ebc12a
commit 3d3cfe1408
5 changed files with 143 additions and 1 deletions

View File

@@ -0,0 +1,128 @@
<template>
<div>
<el-button type="success" icon="el-icon-upload" v-hasPermi="['business:wmblankinventory:edit']" size="mini" @click="handleImport"
>导入</el-button
>
<el-dialog v-loading="upload.isUploading" :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
name="file"
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" @click="importTemplate">下载模板</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
props: {
url: {
type: String,
default: '/',
},
title: {
type: String,
default: '导入',
},
templateUrl: {
type: String,
default: '/',
},
templateTitle: {
type: String,
default: '导入模板',
},
},
data() {
return {
upload: {
// 用户导入参数
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: '',
// 是否加载中,禁用上传
isUploading: false,
// 设置上传的请求头部
headers: { Authorization: 'Bearer ' + getToken() },
// 上传的地址
url: '',
templateTitle: '导入模板',
templateUrl: '',
},
}
},
methods: {
// 打开页面
handleImport() {
this.upload.open = true
this.upload.title = this.title
this.upload.templateTitle = this.templateTitle
this.upload.templateUrl = this.templateUrl
this.upload.url = process.env.VUE_APP_BASE_API + this.url
},
openDialog() {
this.upload.open = true
},
closeDialog() {
this.upload.open = false
},
//清空数据
clear() {},
// 刷新外部数据
refresh() {
this.$emit('refresh')
},
//提交上传文件
submit() {
this.$refs.upload.submit()
},
//todo 下载模板
importTemplate() {
// @/utils/ruoyi"
this.download(this.templateUrl, this.templateTitle)
},
//文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true
},
//文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.isUploading = false
this.$refs.upload.clearFiles()
if (response.code == 200) {
this.$alert(response.data, '导入结果', { dangerouslyUseHTMLString: true })
} else {
this.$alert(response.msg, '导入结果', {
dangerouslyUseHTMLString: true,
type: 'error',
})
}
this.$emit('uploadSuccess')
this.refresh()
},
},
}
</script>
<style></style>