Showing
2 changed files
with
18 additions
and
19 deletions
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | > |
12 | 12 | <div class="w-full h-full" ref="loadingRef"> |
13 | 13 | <div class="flex justify-end"> |
14 | - <Button @click="handleTemplateDownload" type="link">EXCEL模板下载</Button> | |
14 | + <Button @click="handleTemplateDownload" type="link">excel模板下载</Button> | |
15 | 15 | </div> |
16 | 16 | <div class="flex justify-evenly items-center h-50 !w-full"> |
17 | 17 | <Upload |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | > |
36 | 36 | <div class="flex flex-col justify-center items-center"> |
37 | 37 | <Tooltip> |
38 | - <template #title>使用下载的模板编辑之后在进行导入</template> | |
38 | + <template #title>请使用excel模板编辑之后在进行导入</template> | |
39 | 39 | <img :src="CSVImage" alt="avatar" class="w-20 h-20" /> |
40 | 40 | </Tooltip> |
41 | 41 | </div> |
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 | </template> |
47 | 47 | <script lang="ts" setup> |
48 | 48 | import { ref, unref } from 'vue'; |
49 | - import { Upload, Tooltip } from 'ant-design-vue'; | |
49 | + import { Upload, Tooltip, Button } from 'ant-design-vue'; | |
50 | 50 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
51 | 51 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
52 | 52 | import { useMessage } from '/@/hooks/web/useMessage'; |
... | ... | @@ -178,24 +178,22 @@ |
178 | 178 | } |
179 | 179 | }; |
180 | 180 | |
181 | - // const downloadFile = (data: string, fileName: string, type: string, ext: string) => { | |
182 | - // const blob = new Blob([data], { type: type }); | |
183 | - // const objectURL = URL.createObjectURL(blob); | |
184 | - // const element = document.createElement('a'); | |
185 | - // element.href = objectURL; | |
186 | - // element.download = `${fileName}.${ext}`; | |
187 | - // element.style.display = 'none'; | |
188 | - // document.body.appendChild(element); | |
189 | - // element.click(); | |
190 | - // element.remove(); | |
191 | - // URL.revokeObjectURL(objectURL); | |
192 | - // }; | |
181 | + const downloadFile = (data: Blob, fileName: string, ext: string) => { | |
182 | + const objectURL = URL.createObjectURL(data); | |
183 | + const element = document.createElement('a'); | |
184 | + element.href = objectURL; | |
185 | + element.download = `${fileName}.${ext}`; | |
186 | + element.style.display = 'none'; | |
187 | + document.body.appendChild(element); | |
188 | + element.click(); | |
189 | + element.remove(); | |
190 | + URL.revokeObjectURL(objectURL); | |
191 | + }; | |
193 | 192 | |
194 | 193 | // 模板下载 |
195 | - const handleTemplateDownload = () => { | |
196 | - const res = excelExport(); | |
197 | - // eslint-disable-next-line no-console | |
198 | - console.log(res, 'res'); | |
194 | + const handleTemplateDownload = async () => { | |
195 | + const res = await excelExport(); | |
196 | + downloadFile(res, '物模型属性导入模板', 'xls'); | |
199 | 197 | }; |
200 | 198 | |
201 | 199 | const handleCancel = () => { | ... | ... |