Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Add handleExport method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed Oct 24, 2023
1 parent f4ae56c commit 6dabd7d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/views/product/info/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<a-button type="primary" @click="handleOnStatus(0)"> 批量启用</a-button>
<a-button type="primary" @click="handleOnStatus(1)"> 批量禁用</a-button>
<a-button type="primary" @click="handleImport"> 导入</a-button>
<a-button type="primary" @click=""> 导出</a-button>
<a-button type="primary" @click="handleExport"> 导出</a-button>
<a-button type="primary" @click="handleBatchProductInfo"> 批量编辑</a-button>
<a-button type="primary" @click=""> 修正库存</a-button>
</template>
Expand Down Expand Up @@ -50,6 +50,7 @@ import ProductInfoModal from "@/views/product/info/components/ProductInfoModal.v
import BatchEditModal from "@/views/product/info/components/BatchEditModal.vue";
import {getProductInfo, deleteProduct, updateProductStatus} from "@/api/product/product";
import ImportFileModal from "@/components/Tools/ImportFileModal.vue";
import {exportXlsx} from "@/api/basic/common";
export default defineComponent({
name: 'ProductInfo',
Expand Down Expand Up @@ -155,6 +156,29 @@ export default defineComponent({
importModalRef.value.title = "商品信息数据导入";
}
const getTimestamp = (date) => {
return (
date.getFullYear() * 10000000000 +
(date.getMonth() + 1) * 100000000 +
date.getDate() * 1000000 +
date.getHours() * 10000 +
date.getMinutes() * 100 +
date.getSeconds()
).toString();
};
async function handleExport() {
const file = await exportXlsx("商品信息列表")
const blob = new Blob([file]);
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
const timestamp = getTimestamp(new Date());
link.download = "商品信息数据" + timestamp + ".xlsx";
link.target = "_blank";
link.click();
}
return {
registerTable,
handleCreate,
Expand All @@ -169,6 +193,7 @@ export default defineComponent({
batchProductInfoModalRef,
handleBatchProductInfo,
handleImport,
handleExport,
importModalRef
}
}
Expand Down

0 comments on commit 6dabd7d

Please sign in to comment.