123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- export default {
- methods: {
- //导入按钮
- importButton(func, name = '导入', params, fun1, fun2) {
- return (
- <el-upload
- action={'_'}
- show-file-list={false}
- http-request={data => {
- const loading = this.$loading({
- lock: true,
- text: '正在导入',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- })
- fun1 && fun1()
- var formdata = new FormData()
- formdata.append('file', data.file)
- if (!!params) {
- for (const key in params) {
- if (Object.hasOwnProperty.call(params, key)) {
- formdata.append(key, params[key])
- }
- }
- }
- func({ formdata })
- .then(res => {
- fun2 && fun2(res)
- this.$refs.pageRef.refreshList()
- loading.close()
- this.$message({
- type: 'success',
- message: '导入成功!'
- })
- })
- .catch(err => {
- fun2 && fun2()
- loading.close()
- this.$message({
- type: 'error',
- message: err.message || '导入失败'
- })
- })
- }}
- >
- <span class="teshudeshangchuananniu">{name}</span>
- </el-upload>
- )
- }
- }
- }
|