Explorar o código

采购单导出

xiaodai2017 hai 1 ano
pai
achega
7fe5a99761

+ 2 - 1
src/utils/btnList.ts

@@ -45,6 +45,7 @@ const btnList = [
   { code: "044", name: "财务设置税务类目" },
   { code: "045", name: "导出商品税率异常记录" },
   { code: "046", name: "打印对账单" },
-  { code: "047", name: "打印备库单" }
+  { code: "047", name: "打印备库单" },
+  { code: "048", name: "导出" }
 ];
 export default btnList;

+ 1 - 1
src/views/InvoiceSales/invoiceApply/components/add-edit-form/search-batch.vue

@@ -39,7 +39,7 @@ async function onSearch(sequenceNo = []) {
     ...props.payload,
     sequenceNo: sequenceNo.join(","),
     inv_is: "1",
-    cat_status: "1",
+    cat_status: "2",
     inv_status: "0",
     page,
     size

+ 1 - 1
src/views/InvoiceSales/invoiceApply/components/add-edit-form/search-check.vue

@@ -70,7 +70,7 @@ async function onSearch() {
   const { code, data, message } = await httpOrderList({
     ...props.payload,
     inv_is: "1",
-    cat_status: "1",
+    cat_status: "2",
     inv_status: "0",
     ...otherParams,
     page,

+ 17 - 0
src/views/purchase/porder/config/content.config.ts

@@ -12,6 +12,12 @@ import {
 } from "/@/utils/status";
 
 const columns = [
+  {
+    width: 40,
+    type: "selection",
+    align: "center",
+    fixed: "left"
+  },
   {
     label: "采购单编码",
     prop: "sequenceNo",
@@ -78,11 +84,22 @@ const columns = [
     prop: "goodName",
     width: "180px"
   },
+  {
+    label: "税率",
+    prop: "tax",
+    width: "45px"
+  },
   {
     label: "商品数量",
     prop: "goodNum",
     width: "80px"
   },
+  {
+    label: "商品单价",
+    prop: "goodPrice",
+    width: "80px"
+  },
+
   {
     label: "商品总价",
     prop: "totalPrice",

+ 25 - 0
src/views/purchase/porder/config/xls-template.ts

@@ -0,0 +1,25 @@
+export const template = {
+  采购单编码: "",
+  采购主单编码: "",
+  销售订单编码: "",
+  供应商端: "",
+  状态: "",
+  销售单发货状态: "",
+  入库状态: "",
+  订单来源: "",
+  商品来源: "",
+  支付方式: "",
+  商品编码: "",
+  商品名称: "",
+  税率: "",
+  商品数量: "",
+  商品单价: "",
+  商品总价: "",
+  卖出方公司编码: "",
+  卖出方公司名称: "",
+  备库单编码: "",
+  采购员: "",
+  买入方公司编号: "",
+  买入方公司名称: "",
+  创建时间: ""
+};

+ 97 - 4
src/views/purchase/porder/index.vue

@@ -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>