|
@@ -0,0 +1,78 @@
|
|
|
+<template>
|
|
|
+ <xn-form-container title="冷链设备导入" :width="'60%'" :visible="visible" :destroy-on-close="true" @close="onClose">
|
|
|
+ <span
|
|
|
+ >导入数据格式严格按照系统模板进行数据录入,请点击
|
|
|
+ <a-button type="primary" size="small" @click="onDownload">下载模板</a-button>
|
|
|
+ </span>
|
|
|
+ <a-divider dashed />
|
|
|
+ <div>
|
|
|
+ <a-spin :spinning="impUploadLoading">
|
|
|
+ <a-upload-dragger :show-upload-list="false" :custom-request="onUpload" accept=".xls">
|
|
|
+ <p class="ant-upload-drag-icon">
|
|
|
+ <inbox-outlined></inbox-outlined>
|
|
|
+ </p>
|
|
|
+ <p class="ant-upload-text">单击或拖动文件到此区域进行上传</p>
|
|
|
+ <p class="ant-upload-hint">仅支持xls格式文件</p>
|
|
|
+ </a-upload-dragger>
|
|
|
+ </a-spin>
|
|
|
+ </div>
|
|
|
+ </xn-form-container>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+ import memApi from '@/api/basicset/memApi'
|
|
|
+ const emit = defineEmits({ successful: null })
|
|
|
+ const visible = ref(false) // 默认是关闭状态
|
|
|
+
|
|
|
+ const impUploadLoading = ref(false)
|
|
|
+
|
|
|
+ // 打开抽屉
|
|
|
+ const onOpen = (record) => {
|
|
|
+ visible.value = true
|
|
|
+ }
|
|
|
+ // 关闭抽屉
|
|
|
+ const onClose = () => {
|
|
|
+ visible.value = false
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确定导入
|
|
|
+ const onUpload = (data) => {
|
|
|
+ console.log(data, 'xxxxxxxxx')
|
|
|
+
|
|
|
+ // impUploadLoading.value = true
|
|
|
+ const fileData = new FormData()
|
|
|
+
|
|
|
+ fileData.append('file', data.file)
|
|
|
+ console.log(fileData, 'lalal ')
|
|
|
+
|
|
|
+ memApi
|
|
|
+ .upload(fileData)
|
|
|
+ .then((res) => {
|
|
|
+ visible.value = false
|
|
|
+ impUploadLoading.value = false
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ impUploadLoading.value = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确定导出 模板
|
|
|
+ const onDownload = () => {
|
|
|
+ memApi.download().then((res) => {
|
|
|
+ const blob = res.data
|
|
|
+ const url = window.URL.createObjectURL(blob)
|
|
|
+ const link = document.createElement('a')
|
|
|
+ link.href = url
|
|
|
+ link.download = '冷链设备模板'
|
|
|
+ link.click()
|
|
|
+ window.URL.revokeObjectURL(url)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用这个函数将子组件的一些数据和方法暴露出去
|
|
|
+ defineExpose({
|
|
|
+ onOpen
|
|
|
+ })
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|