From 5e64a06a649e9a1e2ea693537f04f31cdc9be9f7 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Tue, 17 May 2022 14:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/api.js | 3 +- src/utils/util.js | 17 +++- src/views/customer/AddCustomer.vue | 125 +++++++++++++++++++---------- 3 files changed, 102 insertions(+), 43 deletions(-) diff --git a/src/utils/api.js b/src/utils/api.js index 45a8ce2..8edaba2 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -39,7 +39,8 @@ export default { updateCustomerByRoleId: `nakadai/nakadai/customer/updateCustomerByRoleId`, checkEmailOrPhone: `nakadai/nakadai/customer/checkEmailOrPhone`, // 新增客户前:校验手机号或者邮箱 getProductsSubscribedByCustomers: `nakadai/nakadai/customer/getProductsSubscribedByCustomers`, - orderBulkDisableEnable: `/nakadai/nakadai/orderOther/orderBulkDisableEnable`, + orderBulkDisableEnable: `nakadai/nakadai/orderOther/orderBulkDisableEnable`, + exportSubscribedRecords: `nakadai/nakadai/order/exportSubscribedRecords`, resetPwdCustomer: `nakadai/nakadai/customer/resetPwd`, queryCustomerIsExists: `nakadai/nakadai/customer/queryCustomerIsExists`, diff --git a/src/utils/util.js b/src/utils/util.js index 92a55f5..97025c4 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -24,7 +24,22 @@ const util = { }); } return result; - } + }, + // 传入文件名和数据,下载文件 + downloadFileDirect(fileName,data) { + if ('download' in document.createElement('a')) { // 非IE下载 + const elink = document.createElement('a') + elink.download = fileName + elink.style.display = 'none' + elink.href = URL.createObjectURL(data) + document.body.appendChild(elink) + elink.click() + URL.revokeObjectURL(elink.href) // 释放URL 对象 + document.body.removeChild(elink) + } else { // IE10+下载 + navigator.msSaveBlob(data, fileName) + } + }, }; export default util; \ No newline at end of file diff --git a/src/views/customer/AddCustomer.vue b/src/views/customer/AddCustomer.vue index 566e326..233f97f 100644 --- a/src/views/customer/AddCustomer.vue +++ b/src/views/customer/AddCustomer.vue @@ -83,13 +83,13 @@