import { getToken } from '@/utils/auth'

export default {
  data() {
    return {
      serviceLevel: [{ id: '', value: '请选择' }, { id: 1, value: '一级' }, { id: 2, value: '二级' }, { id: 3, value: '三级' }],
      serviceCategoryList: [{ id: '', value: '请选择' }, { id: 1, value: '个人' }, { id: 2, value: '企业' }]
    }
  },
  methods: {
    downloadWithUrl(url, name, options = {}) {
      return fetch(url, {
        headers: {
          'x-token': getToken()
        },
        ...options
      })
        .then((data) => data.blob())
        .then((res) => {
          const a = document.createElement('a')
          a.href = URL.createObjectURL(res)
          a.download = name
          a.click()
        })
    },
    uploadSuccess($event, name) {
      console.log($event)
      this.formLabelAlign[name] = $event.fileList.map(e => ({ image: e.response?.data || '', fileName: e.name }))
    },
    handleRemove($event, name) {
      console.log($event, name)
      this.formLabelAlign[name] = $event.fileList.map(e => ({ image: e.response?.data || '', fileName: e.name }))
    }
  }
}
