功能变化:

1.文件导入优化;
pull/84/head
猿小天 2023-01-02 21:41:54 +08:00
parent a319030271
commit 62943431f2
2 changed files with 35 additions and 42 deletions

View File

@ -4,32 +4,34 @@
<slot>导入</slot> <slot>导入</slot>
</el-button> </el-button>
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload <div v-loading="loading">
ref="upload" <el-upload
:limit="1" ref="upload"
accept=".xlsx, .xls" :limit="1"
:headers="upload.headers" accept=".xlsx, .xls"
:action="upload.url" :headers="upload.headers"
:disabled="upload.isUploading" :action="upload.url"
:on-progress="handleFileUploadProgress" :disabled="upload.isUploading"
:on-success="handleFileSuccess" :on-progress="handleFileUploadProgress"
:auto-upload="false" :on-success="handleFileSuccess"
drag :auto-upload="false"
> drag
<i class="el-icon-upload"/> >
<div class="el-upload__text"> <i class="el-icon-upload"/>
将文件拖到此处 <div class="el-upload__text">
<em>点击上传</em> 将文件拖到此处
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip" style="color:red">提示仅允许导入xlsxlsx格式文件</div>
</el-upload>
<div>
<el-button type="warning" style="font-size:14px;margin-top: 20px" @click="importTemplate"></el-button>
<el-button type="warning" style="font-size:14px;margin-top: 20px" @click="updateTemplate"></el-button>
</div> </div>
<div slot="tip" class="el-upload__tip" style="color:red">提示仅允许导入xlsxlsx格式文件</div>
</el-upload>
<div>
<el-button type="warning" style="font-size:14px;margin-top: 20px" @click="importTemplate"></el-button>
<el-button type="warning" style="font-size:14px;margin-top: 20px" @click="updateTemplate"></el-button>
</div> </div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button> <el-button type="primary" :disabled="loading" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button> <el-button :disabled="loading" @click="upload.open = false"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -75,6 +77,11 @@ export default {
} }
} }
}, },
data(){
return {
loading:false
}
},
methods: { methods: {
/** 导入按钮操作 */ /** 导入按钮操作 */
handleImport () { handleImport () {
@ -107,17 +114,17 @@ export default {
const that = this const that = this
// that.upload.open = false // that.upload.open = false
that.upload.isUploading = false that.upload.isUploading = false
that.loading = true
that.$refs.upload.clearFiles() that.$refs.upload.clearFiles()
// //
return request({ return request({
url: that.importApi, url: util.baseURL() + that.api + 'import_data/',
method: 'post', method: 'post',
data: { data: {
url: response.data.url, url: response.data.url
updateSupport: that.upload.updateSupport
} }
}).then(response => { }).then(response => {
// this.$alert("", "", { dangerouslyUseHTMLString: true }); that.loading = false
that.$alert('导入成功', '导入完成', { that.$alert('导入成功', '导入完成', {
confirmButtonText: '确定', confirmButtonText: '确定',
callback: action => { callback: action => {
@ -129,21 +136,7 @@ export default {
// //
submitFileForm () { submitFileForm () {
this.$refs.upload.submit() this.$refs.upload.submit()
},
getUpdateField () {
const that = this
if (that.updateFieldApi) {
return request({
url: that.updateFieldApi,
method: 'get'
}).then(res => {
that.fieldOptions = res.data
})
}
} }
},
mounted () {
this.getUpdateField()
} }
} }
</script> </script>

View File

@ -165,7 +165,7 @@ export const crudOptions = (vm) => {
component: { component: {
placeholder: '请选择是否管理员', placeholder: '请选择是否管理员',
show (context) { show (context) {
return !!vm.info.is_superuser return vm.info.is_superuser
} }
} }
} }