diff --git a/src/api/device/instance.ts b/src/api/device/instance.ts index 4e6f07c4..db7583ec 100644 --- a/src/api/device/instance.ts +++ b/src/api/device/instance.ts @@ -85,6 +85,7 @@ export const batchDeleteDevice = (data: string[]) => server.put(`/device-instanc */ export const deviceTemplateDownload = (productId: string, type: string) => `${BASE_API_PATH}/device-instance/${productId}/template.${type}` +export const templateDownload = (productId: string, type: string) => server.get(`/device-instance/${productId}/template.${type}`,{},{responseType: 'blob'}) /** * 设备导入 * @param productId 产品id diff --git a/src/api/iot-card/cardManagement.ts b/src/api/iot-card/cardManagement.ts index 4c038b9f..4b7441bc 100644 --- a/src/api/iot-card/cardManagement.ts +++ b/src/api/iot-card/cardManagement.ts @@ -99,6 +99,12 @@ export const _import = (configId: any, params: any) => server.get(`/network/card */ export const _export = (format: string, data: any) => server.post(`/network/card/download.${format}/_query`, data, { responseType: 'blob' }); +/** + * 下载模板 + * @param format 类型 xlsx、csv + */ +export const exportCard = (format: string) => server.get(`/network/card/template.${format}`,{},{responseType: 'blob'}); + /** * 验证iccid * @param id diff --git a/src/components/NormalUpload/index.vue b/src/components/NormalUpload/index.vue index 6eb48c6d..2e3eac41 100644 --- a/src/components/NormalUpload/index.vue +++ b/src/components/NormalUpload/index.vue @@ -36,8 +36,8 @@ import { FILE_UPLOAD } from '@/api/comm' import { TOKEN_KEY } from '@/utils/variable'; import { LocalStore } from '@/utils/comm'; -import { downloadFile } from '@/utils/utils'; -import { deviceImport, deviceTemplateDownload } from '@/api/device/instance' +import { downloadFile, downloadFileByUrl } from '@/utils/utils'; +import { deviceImport, deviceTemplateDownload ,templateDownload} from '@/api/device/instance' import { EventSourcePolyfill } from 'event-source-polyfill' import { message } from 'ant-design-vue'; @@ -72,8 +72,20 @@ const flag = ref(false) const count = ref(0) const errMessage = ref('') -const downFile = (type: string) => { - downloadFile(deviceTemplateDownload(props.product, type)); +const downFile =async (type: string) => { + // downloadFile(deviceTemplateDownload(props.product, type)); + const res:any =await templateDownload(props.product, type) + if(res){ + const blob = new Blob([res], { type: type }); + const url = URL.createObjectURL(blob); + console.log(url); + downloadFileByUrl( + url, + `设备导入模版`, + type, + ); + } + } const submitData = async (fileUrl: string) => { diff --git a/src/views/device/Instance/Detail/Parsing/index.vue b/src/views/device/Instance/Detail/Parsing/index.vue index 5aebe4e2..c69af54a 100644 --- a/src/views/device/Instance/Detail/Parsing/index.vue +++ b/src/views/device/Instance/Detail/Parsing/index.vue @@ -146,12 +146,6 @@ const rest = async () => { getDeviceCode(); message.success('操作成功') } - // service.delDeviceCode(productId, deviceId).then((res) => { - // if (res.status === 200) { - // getDeviceCode(productId, deviceId); - // onlyMessage('操作成功'); - // } - // }); }; //获取topic const getTopic = async () => { @@ -285,7 +279,7 @@ onMounted(() => { display: flex; justify-content: space-between; padding: 10px; - background-color: '#f7f7f7'; + background-color: #f7f7f7; .bottom-title { display: flex; diff --git a/src/views/device/Product/Detail/DataAnalysis/index.vue b/src/views/device/Product/Detail/DataAnalysis/index.vue index 07deadd9..4fbe01a1 100644 --- a/src/views/device/Product/Detail/DataAnalysis/index.vue +++ b/src/views/device/Product/Detail/DataAnalysis/index.vue @@ -60,7 +60,7 @@ -