YangJian0701 1 year ago
parent
commit
29a75fafa5

+ 3 - 0
package.json

@@ -13,13 +13,16 @@
     "core-js": "^3.8.3",
     "echarts": "^5.4.3",
     "element-plus": "^2.4.2",
+    "file-saver": "^2.0.5",
     "js-md5": "^0.8.3",
     "qs": "^6.11.2",
     "register-service-worker": "^1.7.2",
     "three": "^0.158.0",
     "vue": "^3.2.13",
     "vue-class-component": "^8.0.0-0",
+    "vue-print-nb": "^1.7.5",
     "vue-router": "^4.0.3",
+    "vue3-print-nb": "^0.1.4",
     "vuex": "^4.0.0",
     "vuex-persistedstate": "^4.1.0",
     "xlsx": "^0.18.5"

+ 124 - 15
public/index.html

@@ -1,17 +1,126 @@
 <!DOCTYPE html>
 <html lang="">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width,initial-scale=1.0">
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
-    <title><%= htmlWebpackPlugin.options.title %></title>
-  </head>
-  <body>
-    <noscript>
-      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
-    </noscript>
-    <div id="app"></div>
-    <!-- built files will be auto injected -->
-  </body>
-</html>
+
+<head>
+  <meta charset="utf-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width,initial-scale=1.0">
+  <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+  <title>
+    <%= htmlWebpackPlugin.options.title %>
+  </title>
+  <style>
+    * {
+      margin: 0;
+      padding: 0;
+    }
+
+    .loadingSpinn {
+      height: 100vh;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+    }
+
+    .atom-spinner,
+    .atom-spinner * {
+      box-sizing: border-box;
+    }
+
+    .atom-spinner {
+      height:100px;
+      width: 100px;
+      overflow: hidden;
+    }
+
+    .atom-spinner .spinner-inner {
+      position: relative;
+      display: block;
+      height: 100%;
+      width: 100%;
+    }
+
+    .atom-spinner .spinner-circle {
+      display: block;
+      position: absolute;
+      color: #409eff;
+      font-size: calc(60px * 0.24);
+      top: 50%;
+      left: 50%;
+      transform: translate(-50%, -50%);
+    }
+
+    .atom-spinner .spinner-line {
+      position: absolute;
+      width: 100%;
+      height: 100%;
+      border-radius: 50%;
+      animation-duration: 1s;
+      border-left-width: calc(60px / 25);
+      border-top-width: calc(60px / 25);
+      border-left-color: #409eff;
+      border-left-style: solid;
+      border-top-style: solid;
+      border-top-color: transparent;
+    }
+
+    .atom-spinner .spinner-line:nth-child(1) {
+      animation: atom-spinner-animation-1 1s linear infinite;
+      transform: rotateZ(120deg) rotateX(66deg) rotateZ(0deg);
+    }
+
+    .atom-spinner .spinner-line:nth-child(2) {
+      animation: atom-spinner-animation-2 1s linear infinite;
+      transform: rotateZ(240deg) rotateX(66deg) rotateZ(0deg);
+    }
+
+    .atom-spinner .spinner-line:nth-child(3) {
+      animation: atom-spinner-animation-3 1s linear infinite;
+      transform: rotateZ(360deg) rotateX(66deg) rotateZ(0deg);
+    }
+
+    @keyframes atom-spinner-animation-1 {
+      100% {
+        transform: rotateZ(120deg) rotateX(66deg) rotateZ(360deg);
+      }
+    }
+
+    @keyframes atom-spinner-animation-2 {
+      100% {
+        transform: rotateZ(240deg) rotateX(66deg) rotateZ(360deg);
+      }
+    }
+
+    @keyframes atom-spinner-animation-3 {
+      100% {
+        transform: rotateZ(360deg) rotateX(66deg) rotateZ(360deg);
+      }
+    }
+  </style>
+</head>
+
+<body>
+  <noscript>
+    <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript
+        enabled.Please enable it to continue.</strong>
+  </noscript>
+  <div id="app">
+    <div class="loadingSpinn">
+      <div class="atom-spinner">
+        <div class="spinner-inner">
+          <div class="spinner-line"></div>
+          <div class="spinner-line"></div>
+          <div class="spinner-line"></div>
+          <!--Chrome renders little circles malformed :(-->
+          <div class="spinner-circle">
+            &#9679;
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+  <!-- built files will be auto injected -->
+
+</body>
+
+</html>

+ 3 - 0
src/api/index.ts

@@ -9,6 +9,9 @@ export * from './module/essentialinfo'
 export * from './module/transmitReceive'
 export * from './module/storagePut'
 export * from './module/storageFrom'
+export * from './module/print'//打印,导出
+
+export * from './module/home'
 
 
 

+ 9 - 0
src/api/module/home.ts

@@ -0,0 +1,9 @@
+
+import $http from '@/utils/index'
+
+/**
+ * bar-row数据
+ * @param params 
+ * @returns 
+ */
+export const homeList = (params: any) => $http.post('/stock/stat', params)

+ 9 - 0
src/api/module/print.ts

@@ -0,0 +1,9 @@
+
+import $http from '@/utils/index'
+
+// 导出pdf
+export const inventPDF = (params: any) => $http.post('/stock-template/inventory/pdf', params, { responseType: "blob", })
+
+// Excel
+export const inventExcel = (params: any) => $http.post('/stock-template/inventory/excel', params, { responseType: "blob", })
+

+ 95 - 0
src/components/echart/echart-bar-row.vue

@@ -0,0 +1,95 @@
+<!-- 柱图 -->
+<template>
+    <div style="height:100%;min-height: 300px;" :id="props.id" class="myChart"></div>
+</template>
+<script setup lang="ts">
+import { onMounted, inject, watch, reactive } from "vue";
+import { findBarRowFun } from "@/plugins/findData";
+// 接受父组件参数,配置默认值
+const props = defineProps({
+    id: {
+        type: String,
+        default: () => '',
+    },
+    lineData: {
+        type: Object,
+        default: () => { },
+    },
+});
+
+let echart: any = null
+let myChart: any = null
+
+let echartData: any = reactive({})
+
+watch(() => props.lineData, async () => {
+    Object.assign(echartData,findBarRowFun(props.lineData))
+    myChart.clear();
+    myChart.setOption(initEcharts());
+})
+onMounted(() => {
+    echart = inject('echart')
+    myChart = echart.init(document.getElementById(props.id));
+    setEchartFun();
+})
+
+//函数
+const setEchartFun = async () => {
+    myChart.setOption(initEcharts());
+    window.onresize = function () {
+        myChart.resize();
+    };
+}
+const initEcharts = () => {
+    // 绘制图表
+    return {
+        title: {},
+        tooltip: {
+            // trigger: 'axis',
+            // axisPointer: {
+            //     type: 'shadow'
+            // }
+        },
+        legend: {},
+        grid: {
+            top:'0%',
+            left: '0%',
+            right: '4%',
+            bottom: '3%',
+            containLabel: true
+        },
+        xAxis: {
+            type: 'value',
+            boundaryGap: [0, 0.01]
+        },
+        yAxis: {
+            type: 'category',
+            data: echartData.xAxisArr
+        },
+        series: [
+            {
+                type: 'bar',
+                data:  echartData.dataServe,
+                barMaxWidth:'20%',//宽度
+                itemStyle: { //面积图颜色设置
+                    color: {
+                        type: 'linear',
+                        x: 0,
+                        y: 0,
+                        x2: 0,
+                        y2: 1,
+                        colorStops: [
+                        { offset: 0, color: 'rgb(51,205,184)' },
+                                    { offset: 0.5, color: 'rgb(51,205,184)' },
+                                    { offset: 1, color: 'rgb(51,205,184)' }
+                        ],
+                        globalCoord: false // 缺省为 false
+                    },
+                    barBorderRadius: [0,20,20,0] //圓角
+                },
+            },
+        ]
+    }
+}
+
+</script>

+ 76 - 49
src/components/echart/echart-bar.vue

@@ -80,64 +80,91 @@ const initEcharts = () => {
         },
         xAxis: {
             type: 'category',
-            data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月']
+            data: ['出库', '入库', '销售出库', '采购入库']
         },
         yAxis: {
             type: 'value'
         },
         series: [
             {
-                data: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],
                 type: 'bar',
-                barMaxWidth:'20%',//宽度
-                itemStyle: { //面积图颜色设置
-                    // normal: {//柱状图上方显示数值
-                    //     label: {
-                    //         show: true, //开启显示
-                    //         position: 'top', //顶部显示
-                    //         textStyle: {
-                    //             //数值样式
-                    //             color: 'black',
-                    //             fontSize: 12,
-                    //         },
-                    //     },
-                    // },
-                    color: {
-                        type: 'linear',
-                        x: 0,
-                        y: 0,
-                        x2: 0,
-                        y2: 1,
-                        colorStops: [
-                            { offset: 0, color: '#5389fd' },
-                            { offset: 0.5, color: '#3a6cf9' },
-                            { offset: 1, color: '#2251f7' }
-                        ],
-                        globalCoord: false // 缺省为 false
+                barMaxWidth: '15%',//宽度
+                data: [
+                    {
+                        value: Math.random() * 1000,
+                        itemStyle: { //面积图颜色设置
+                            color: {
+                                type: 'linear',
+                                x: 0,
+                                y: 0,
+                                x2: 0,
+                                y2: 1,
+                                colorStops: [
+                                    { offset: 0, color: '#5389fd' },
+                                    { offset: 0.5, color: '#3a6cf9' },
+                                    { offset: 1, color: '#2251f7' }
+                                ],
+                                globalCoord: false // 缺省为 false
+                            },
+                            barBorderRadius: [20] //圓角
+                        },
                     },
-                    barBorderRadius: [10] //圓角
-                },
-            },
-            {
-                data: [Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random()],
-                type: 'bar',
-                barMaxWidth:'20%',//宽度
-                itemStyle: { //面积图颜色设置
-                    color: {
-                        type: 'linear',
-                        x: 0,
-                        y: 0,
-                        x2: 0,
-                        y2: 1,
-                        colorStops: [
-                            { offset: 0, color: '#feae4d' },
-                            { offset: 0.5, color: '#f99b45' },
-                            { offset: 1, color: '#fd8c38' }
-                        ],
-                        globalCoord: false // 缺省为 false
+                    {
+                        value: Math.random() * 1000,
+                        itemStyle: { //面积图颜色设置
+                            color: {
+                                type: 'linear',
+                                x: 0,
+                                y: 0,
+                                x2: 0,
+                                y2: 1,
+                                colorStops: [
+                                    { offset: 0, color: '#feae4d' },
+                                    { offset: 0.5, color: '#f99b45' },
+                                    { offset: 1, color: '#fd8c38' }
+                                ],
+                                globalCoord: false // 缺省为 false
+                            },
+                            barBorderRadius: [20] //圓角
+                        },
+                    }, {
+                        value: Math.random() * 1000,
+                        itemStyle: { //面积图颜色设置
+                            color: {
+                                type: 'linear',
+                                x: 0,
+                                y: 0,
+                                x2: 0,
+                                y2: 1,
+                                colorStops: [
+                                    { offset: 0, color: 'rgb(51,205,184)' },
+                                    { offset: 0.5, color: 'rgb(51,205,184)' },
+                                    { offset: 1, color: 'rgb(51,205,184)' }
+                                ],
+                                globalCoord: false // 缺省为 false
+                            },
+                            barBorderRadius: [20] //圓角
+                        },
+                    }, {
+                        value: Math.random() * 1000,
+                        itemStyle: { //面积图颜色设置
+                            color: {
+                                type: 'linear',
+                                x: 0,
+                                y: 0,
+                                x2: 0,
+                                y2: 1,
+                                colorStops: [
+                                    { offset: 0, color: 'rgb(252,108,150)' },
+                                    { offset: 0.5, color: 'rgb(252,108,150)' },
+                                    { offset: 1, color: 'rgb(252,108,150)' }
+                                ],
+                                globalCoord: false // 缺省为 false
+                            },
+                            barBorderRadius: [20] //圓角
+                        },
                     },
-                    barBorderRadius: [10] //圓角
-                },
+                ]
             }
         ]
     }

+ 0 - 2
src/main.ts

@@ -6,8 +6,6 @@ import store from './store'
 const app = createApp(App)
 
 
-
-
 import 'element-plus/theme-chalk/index.css'  // 引入组件样式
 import ElementPlus from 'element-plus'
 

+ 10 - 88
src/plugins/findData.ts

@@ -6,95 +6,17 @@
  * @param swiData 当前的swi为按月true,按年false
  */
 
-export default function findDataFun(type:any,data:any,swiData:any){
-    if(type=='bar'){
-        return barFun(data,swiData)
-    }else{
-        return lineFun(data,swiData)
-    }
-}
-
-//筛选bar
-function barFun(data:any,swiData:any) {
-    const paramData:any = {
-        titles:'',//标题
-        xAxisArr:[],//x轴
-        seriesDiscount:[], //合同总金额
-        seriesRecoveries:[] //合同已回款金额
-    }
-    if(swiData){//按月
-        if(data.ContractMoneyByMonth){
-            data.ContractMoneyByMonth.forEach((item:any) => {
-                paramData.titles = '月度合同金额统计(元)'
-                paramData.xAxisArr.push(item.T_date + '月')
-                paramData.seriesDiscount.push(item.T_discount)
-                paramData.seriesRecoveries.push(item.T_recoveries_money)
-            });
-        }else{
-            paramData.titles = '月度合同金额统计(元)'
-            paramData.xAxisArr = []
-            paramData.seriesDiscount = []
-            paramData.seriesRecoveries = []
 
-        }
-       
-    }else{//按年
-        if(data.ContractMoneyByYear){
-            data.ContractMoneyByYear.forEach((item:any) => {
-                paramData.titles = '年度合同金额统计(元)'
-                paramData.xAxisArr.push(item.T_date + '年')
-                paramData.seriesDiscount.push(item.T_discount)
-                paramData.seriesRecoveries.push(item.T_recoveries_money)
-            });
-        }else{
-            paramData.titles = '年度合同金额统计(元)'
-                paramData.xAxisArr = []
-                paramData.seriesDiscount = []
-                paramData.seriesRecoveries = []
-        }
-        
+//筛选bar-row
+export function findBarRowFun(arr:any) {
+    let obj:any = {
+        xAxisArr: [],//x轴
+        dataServe:[]
     }
-    return paramData
+    arr.forEach((item:any) => {
+        obj.xAxisArr.push(item.product_name + item.spec_name)
+        obj.dataServe.push(item.balance)
+    });
+    return obj
 }
 
-//筛选line
-function lineFun(data:any,swiData:any) {
-    const paramData:any = {
-        tooltip:'',
-        titles:'',//标题
-        xAxisArr:[],//x轴
-        seriesArr:[], //合同数量
-    }
-    if(swiData){//按月
-        if(data.ContractNumByMonth){
-            data.ContractNumByMonth.forEach((item:any) => {
-                paramData.tooltip = '月度(份)'
-                paramData.titles = '月度合同数量(份)'
-                paramData.xAxisArr.push(item.T_date + '月')
-                paramData.seriesArr.push(item.T_num)
-            });
-        }else{
-            paramData.tooltip = '月度(份)'
-            paramData.titles = '月度合同数量(份)'
-            paramData.xAxisArr = []
-            paramData.seriesArr = []
-        }
-        
-    }else{//按年
-        if(data.ContractNumByYear){
-            data.ContractNumByYear.forEach((item:any) => {
-                paramData.tooltip = '年度(份)'
-                paramData.titles = '年度合同数量(份)'
-                paramData.xAxisArr.push(item.T_date + '年')
-                paramData.seriesArr.push(item.T_num)
-            });
-        }else{
-            paramData.tooltip = '年度(份)'
-            paramData.titles = '年度合同数量(份)'
-            paramData.xAxisArr = []
-            paramData.seriesArr = []
-        }
-        
-    }
-    return paramData
-}

+ 1 - 0
src/plugins/rulesData.ts

@@ -24,6 +24,7 @@ export let columnsTable = [
     { prop: 'forwardingUnit', label: '发货单位', width: 0 },
     { prop: 'date', label: '入库日期', width: 0 },
 ]
+
 //出库
 export let columnsTableOut = [
     { label: '数量', prop: 'quantity', width: 0 },

+ 125 - 25
src/views/home/index.vue

@@ -9,60 +9,154 @@
         <statistics :imgUrl="require('@/assets/img/1700228167058.jpg')" titles="库存总量" subhea="931"></statistics>
       </bgPure>
     </div>
-    <cards>
+    <div class="home-echarts">
+      <cards class="home-echarts-card2">
+        <template #card-tit>
+          库存统计-图表
+        </template>
+        <template #card-content>
+          <echartBarRow id="bar1" :lineData="data.lineData"></echartBarRow>
+        </template>
+      </cards>
+      <cards class="home-echarts-card1">
         <template #card-tit>
           <div style="display: flex;align-items: center;">
-            <p>单位(栋)</p>
-            <div style="display: flex;align-items: center;margin:0 30px ;">
+            <!-- <p>单位(栋)</p> -->
+            <div style="display: flex;align-items: center;margin:0 30px 0 0;">
               <div style="width: 15px;height: 15px;border-radius: 50%;background: #2251f7;"></div>
-              <p style="margin-left: 10px;">楼宇数量</p>
+              <p style="margin-left: 10px;">出库</p>
             </div>
             <div style="display: flex;align-items: center;">
               <div style="width: 15px;height: 15px;border-radius: 50%;background: #fd8c38;"></div>
-              <p style="margin-left: 10px;">写字楼数量</p>
+              <p style="margin-left: 10px;">入库</p>
+            </div>
+            <div style="display: flex;align-items: center;margin:0 30px ;">
+              <div style="width: 15px;height: 15px;border-radius: 50%;background: rgb(56, 225, 202);"></div>
+              <p style="margin-left: 10px;">销售出库</p>
+            </div>
+            <div style="display: flex;align-items: center;">
+              <div style="width: 15px;height: 15px;border-radius: 50%;background: rgb(253, 109, 151);"></div>
+              <p style="margin-left: 10px;">采购入库</p>
             </div>
           </div>
         </template>
-        <template #card-subhead>行政区划选择</template>
+        <!-- <template #card-subhead>行政区划选择</template> -->
         <template #card-content>
           <echartbar id="bar0"></echartbar>
         </template>
       </cards>
+    </div>
+    <cards style="margin-top: 20px;">
+      <template #card-tit>
+        库存统计-表格
+      </template>
+      <template #card-subhead>
+        <el-select v-model.number="data.initParam.productId" filterable remote reserve-keyword placeholder="疫苗名称"
+            :remote-method="remoteMethod1" :loading="loading" clearable style="width: 200px;"
+            @clear="data.initParam.productId = null" @click="click1" @change="changeFun">
+            <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value" />
+        </el-select>
+      </template>
+      <template #card-content>
+        <tables ref="TableRef" :requestApi="homeList" :columns="columns" :initParam="data.initParam"></tables>
+      </template>
+    </cards>
+
   </div>
 </template>
 
 <script setup lang="ts">
-import { reactive, provide, onMounted } from "vue";
+import { homeList,productList } from "@/api";
+import { provide, onMounted, reactive,ref } from "vue";
 import echartbar from '@/components/echart/echart-bar.vue'
-import echartbarlR from '@/components/echart/echart-bar-LR.vue'
-import echartline from '@/components/echart/echart-line.vue'
+import echartBarRow from '@/components/echart/echart-bar-row.vue'
 import bgPure from '@/components/bgPure.vue'
 import cards from '@/components/card.vue'
 import statistics from '@/components/statistics.vue'
 import { userInfo } from "@/api";
 import { useStore } from "vuex";
+import tables from "@/components/table.vue";
 import * as echarts from 'echarts'
 provide('echart', echarts)
-const data = reactive({
-  tableData: [],
-  tabData: [
-    { label: "疫苗名称", name: "first" },
-    { label: "生产企业", name: "second" },
-    { label: "规格", name: "third" },
-    { label: "剂型", name: "fourth" },
-    { label: "单位", name: "fourth1" },
-  ]
-})
 const store = useStore()
+const TableRef = ref()
 //获取用户信息
-const getuserInfoApi = async ()=>{
-  const result:any = await userInfo({})
-  if(result.code==200)store.commit('setIsUserInfo', result.data) //存储用户个人信息
-} 
-onMounted(()=>{
-  getuserInfoApi()
+const getuserInfoApi = async () => {
+  const result: any = await userInfo({})
+  if (result.code == 200) store.commit('setIsUserInfo', result.data) //存储用户个人信息
+}
+// 渲染表格
+const columns: any = [
+  { type: 'index', label: '编号', width: 80, },
+  { prop: 'product_name', label: '疫苗名称'},
+  { prop: 'spec_name', label: '规格(剂/支或粒)'},
+  { prop: 'balance', label: '数量', },
+  { prop: 'unit_name', label: '单位'},
+]
+interface ListItem {
+    value: string
+    label: string
+}
+const list1 = ref<ListItem[]>([])//疫苗名称
+const options1 = ref<ListItem[]>([])
+const loading = ref(false)
+const remoteMethod1 = async (query: string) => {
+    if (query) {
+        loading.value = true
+        setTimeout(() => {
+            loading.value = false
+            options1.value = list1.value.filter((item: any) => {
+                return item.label.toLowerCase().includes(query.toLowerCase())
+            })
+        }, 200)
+    } else {
+        options1.value = []
+    }
+}
+const click1 = async () => { options1.value = list1.value }
+//请求参数
+const data: any = reactive({
+  initParam: {
+    specId: 0,
+    productId: null
+  },
+  lineData:[]
 })
+//函数
+const changeFun = async ()=>{
+  if(data.initParam.productId=="") data.initParam.productId = null
+  TableRef.value?.getTableList()
+  homeListApi()
+}
+// 渲染表格
+onMounted(async () => {
+  const result1: any = await productList({ age: 1, pageSize: 999 })//疫苗名称
+  list1.value = findMap(result1.data.list, 'obj')
 
+})
+onMounted(() => {
+  getuserInfoApi()
+})
+//函数
+const homeListApi = async ()=>{
+  const result:any = await homeList({
+    "page": 1,
+    "pageSize": 9999,
+    "specId": 0,
+    "productId": data.initParam.productId
+  })
+  if(result.code==200 && result.msg=="查询成功"){
+    data.lineData = result.data?.list || []
+  }
+  console.log('result',result)
+}
+homeListApi()
+//函数
+const findMap = (arr: any, obj: any) => {
+    return arr.map((item: any) => {
+        return { value: obj == 'obj' ? item.id : item, label: obj == 'obj' ? item.name : item }
+    })
+}
 </script>
 <style lang="scss">
 .home {
@@ -73,5 +167,11 @@ onMounted(()=>{
     grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
     grid-gap: 20px;
   }
+
+  &-echarts {
+    display: grid;
+    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
+    grid-gap: 20px;
+  }
 }
 </style>

+ 15 - 21
src/views/salesmanagement/storageOrderGoods/down.vue

@@ -34,13 +34,14 @@
                 </span>
             </template>
         </el-dialog>
+        {{ data.fileAddress }}
     </div>
 </template>
 
 <script lang="ts" setup>
 import * as XLSX from 'xlsx'
 import { Download } from '@element-plus/icons-vue'
-import { getContentExportApi, downloadExcelFun } from "@/utils/download";
+import { inventPDF,inventExcel } from "@/api";
 import { reactive, ref } from 'vue'
 const dialogFormVisible = ref(false)
 const formLabelWidth = '60px'
@@ -55,34 +56,27 @@ const form = reactive({
     desc: '',
 })
 
-const data = reactive({
-    imgUrl: ''
+const data: any = reactive({
+    imgUrl: '',
+    fileAddress: ""
 })
 //函数
 const printFun = async () => {
-    getContentExportApi({}).then((res) => {
+    inventPDF({}).then((res) => {
         const result: any = res
-        // 实例化 FileReader 对象
-        const reader = new FileReader()
-        // file为文件流
-        reader.readAsBinaryString(result)
-        
-        reader.onload = function () {
-            const binaryStringData = reader.result
-            
-            let printableContent:any = document.getElementById('printable')?.innerHTML;
-            printableContent = binaryStringData
-            let printWindow: any = window.open('', '_blank');
 
-            printWindow.document.write('<html><head><title>打印内容</title></head><body>' + printableContent + '</body></html>');
-      
-            printWindow.document.close();
-            printWindow.print();
-        }
+        let fileAddress = URL.createObjectURL(new Blob([result], { type: "application/pdf;charset=utf-8" }))
+        let innHtml = window.open(fileAddress, '_blank');
+        innHtml?.print();
 
+        //下载
+        // const FileSaver = require('file-saver')
+        // const blobs = new Blob([result], {type: 'application/pdf;charset=utf-8'}) // 此处type根据你想要的
+        // FileSaver.saveAs(blobs, '11.pdf') // 下载的name文件名
 
         return
-        const blob = new Blob([result], { type:result.type});
+
+        const blob = new Blob([result], { type: result.type });
         console.log(blob);
         let src = window.URL.createObjectURL(blob);
         console.log(src);