导入,导出

<el-button type="primary" @click="exportData">
      <svg-icon class="svg-icon-btn" icon-class="asset_export_excel" />
      导出
    </el-button>
import download from '@/base/utils/download'
// 导出
    exportData() {
      const formInline = this.$refs.TableArea.formInline
      exportData(formInline).then(res => {
        download(res, '单位会计科目')
      })
    }
download.js
/**
 * @default 导出
 */
import { parseTime } from './index'
export default function download(response, name) {
  const blob = new Blob([response], { type: 'application/vnd.ms-excel;charset=utf-8' })
  const downloadElement = document.createElement('a')
  const href = window.URL.createObjectURL(blob)
  downloadElement.href = href
  downloadElement.download = name + parseTime(+new Date()) + '.xls'
  document.body.appendChild(downloadElement)
  downloadElement.click()
  document.body.removeChild(downloadElement)
  window.URL.revokeObjectURL(href)
}
<ImportFile
      :file-name="'财政会计科目'"
      :http-url="'http://39.104.108.253:9909/account/importData'"
      :is-import="false"
      @refresh="refreshEvent"
    />
ImportFile组件
<el-upload
      v-if="isOutput && !isChoice"
      action=""
      :http-request="importOutitem"
      :show-file-list="false"
      :file-list="fileList"
      :limit="1"
      accept=".xlsx"
      style="display: inline-block; margin:0 10px;"
      @on-exceed="fileExceed"
    >
      <el-button type="primary" :loading="loading"><svg-icon class="svg-icon-btn" icon-class="Import" />{{ buttonText }}</el-button>
    </el-upload>
importOutitem(val) {
      this.loading = true
      const form = new FormData()
      form.append('fileName', val.file)
      request({
        url: this.isChoice ? `/${this.httpUrl}/${this.intRemind}` : `${this.httpUrl}`,
        method: 'post',
        data: form,
        timeout: Infinity,
        'Content-Type': 'multipart/form-data'
      }).then(res => {
        if (res.code === 20000) {
          const temp = {}
          const arr = []
          for (var p in res.data.columnlist) {
            if (p === 'strreason') {
              temp.label = res.data.columnlist[p]
              temp.prop = p
            } else {
              arr.push({
                label: res.data.columnlist[p],
                prop: p
              })
            }
          }
          this.head = arr.sort((a, b) => { return a.prop.match(/\d+/g) - b.prop.match(/\d+/g) })
          this.head.unshift(temp)
          this.list = res.data.importtemplatelist
          this.dialog.isShow = true
          this.$emit('refresh')
        }
        this.loading = false
        this.fileList = []
      }).catch(err => {
        this.loading = false
        console.log('catch ' + err) // catch error
        this.fileList = []
      })
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值