1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- export default {
- methods: {
- //导入按钮
- importButton(func, name = '导入', params, fun1, fun2) {
- return () => {
- return (
- <el-upload
- action={'_'}
- http-request={data => {
- 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()
- this.$refs.pageRef.refreshList()
- this.$message({
- type: 'success',
- message: '导入成功!'
- })
- })
- .catch(err => {
- fun2 && fun2()
- this.$message({
- type: 'error',
- message: err.message || '导入失败'
- })
- })
- }}
- >
- <span>{name}</span>
- </el-upload>
- )
- }
- }
- }
- }
|