|
@@ -1,13 +1,26 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { ref } from "vue";
|
|
|
+import { ref, shallowRef } from "vue";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
import contentConfig from "./config/content.config";
|
|
|
import searchConfig from "./config/search.config";
|
|
|
import PurchaseModal from "./components/purchase-modal.vue";
|
|
|
+import { usePermission } from "/@/hooks/core/usePermission";
|
|
|
+import { template } from "./config/xls-template";
|
|
|
import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
|
|
|
-
|
|
|
+import { utils, writeFile } from "xlsx";
|
|
|
+import {
|
|
|
+ cgdStatusOptions,
|
|
|
+ cg_order_source_options,
|
|
|
+ cg_order_type_options,
|
|
|
+ hasAccountOptions,
|
|
|
+ sendStatusOptions,
|
|
|
+ send_status_list
|
|
|
+} from "/@/utils/status";
|
|
|
const PageName = "porder";
|
|
|
+const loading = shallowRef(false);
|
|
|
+const selectlist = ref<any[]>([]);
|
|
|
const purchaseModalRef = ref<InstanceType<typeof PurchaseModal> | null>(null);
|
|
|
-
|
|
|
+const { permissions, hasPermissionWithCode } = usePermission("porder");
|
|
|
const hooks: PageHooks = {
|
|
|
pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
|
|
|
};
|
|
@@ -17,6 +30,75 @@ const events: PageEvents = {
|
|
|
preview: row => purchaseModalRef.value.onDisplay(row)
|
|
|
}
|
|
|
};
|
|
|
+async function handleExport() {
|
|
|
+ if (selectlist.value.length === 0) {
|
|
|
+ ElMessage.warning("请选择一条采购单");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const judieTemplate = template;
|
|
|
+ const judieFilename = "采购单导出";
|
|
|
+
|
|
|
+ const data: any[] = [];
|
|
|
+ selectlist.value.forEach(item => {
|
|
|
+ const _template = { ...judieTemplate };
|
|
|
+
|
|
|
+ _template["采购单编码"] = item.sequenceNo;
|
|
|
+ _template["采购主单编码"] = item.cxCode;
|
|
|
+ _template["销售订单编码"] = item.qrdCode;
|
|
|
+ _template["供应商端"] = item.has_account
|
|
|
+ ? (hasAccountOptions.find(s => s.value == item.has_account + "") || {})
|
|
|
+ .label || ""
|
|
|
+ : "";
|
|
|
+ _template["状态"] = item.status
|
|
|
+ ? (cgdStatusOptions.find(s => s.value == item.status + "") || {}).label ||
|
|
|
+ ""
|
|
|
+ : "";
|
|
|
+ _template["销售单发货状态"] = item.qrdSend
|
|
|
+ ? (send_status_list.find(s => s.value == item.qrdSend + "") || {})
|
|
|
+ .label || ""
|
|
|
+ : "";
|
|
|
+ _template["入库状态"] = item.sendStatus
|
|
|
+ ? (sendStatusOptions.find(s => s.value == item.sendStatus + "") || {})
|
|
|
+ .label || ""
|
|
|
+ : "";
|
|
|
+ _template["订单来源"] = item.cgdSource
|
|
|
+ ? (
|
|
|
+ cg_order_source_options.find(s => s.value == item.cgdSource + "") ||
|
|
|
+ {}
|
|
|
+ ).label || ""
|
|
|
+ : "";
|
|
|
+ _template["商品来源"] = item.cgdType
|
|
|
+ ? (cg_order_type_options.find(s => s.value == item.cgdType + "") || {})
|
|
|
+ .label || ""
|
|
|
+ : "";
|
|
|
+
|
|
|
+ _template["支付方式"] = item.pay_type;
|
|
|
+ _template["商品编码"] = item.goodNo;
|
|
|
+ _template["商品名称"] = item.goodName;
|
|
|
+ _template["税率"] = item.tax;
|
|
|
+ _template["商品数量"] = item.goodNum;
|
|
|
+ _template["商品单价"] = item.goodPrice;
|
|
|
+ _template["商品总价"] = item.totalPrice;
|
|
|
+ _template["卖出方公司编码"] = item.supplierNo;
|
|
|
+ _template["卖出方公司名称"] = item.supplierName;
|
|
|
+ _template["备库单编码"] = item.bkCode;
|
|
|
+ _template["采购员"] = item.ownerName;
|
|
|
+ _template["买入方公司编号"] = item.companyNo;
|
|
|
+ _template["买入方公司名称"] = item.companyName;
|
|
|
+ _template["创建时间"] = item.addtime;
|
|
|
+
|
|
|
+ data.push(_template);
|
|
|
+ });
|
|
|
+ //创建数据表
|
|
|
+ const workBook = utils.book_new();
|
|
|
+ const workSheet = utils.json_to_sheet(data);
|
|
|
+ utils.book_append_sheet(workBook, workSheet, "sheet");
|
|
|
+
|
|
|
+ //导出模板
|
|
|
+ writeFile(workBook, `${judieFilename}.xlsx`, {
|
|
|
+ bookType: "xlsx"
|
|
|
+ });
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -26,7 +108,18 @@ const events: PageEvents = {
|
|
|
:events="events"
|
|
|
:contentConfig="contentConfig"
|
|
|
:search-config="searchConfig"
|
|
|
- />
|
|
|
+ @content-select-change="items => (selectlist = items)"
|
|
|
+ >
|
|
|
+ <template #content_header>
|
|
|
+ <ElButton
|
|
|
+ type="primary"
|
|
|
+ v-if="hasPermissionWithCode('048')"
|
|
|
+ @click="handleExport"
|
|
|
+ :loading="loading"
|
|
|
+ >导出</ElButton
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </PageContainer>
|
|
|
<PurchaseModal ref="purchaseModalRef" />
|
|
|
</PageAuth>
|
|
|
</template>
|