YangJian0701 1 year ago
parent
commit
d29cdf207e

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
     "echarts": "^5.4.3",
     "element-plus": "^2.4.2",
     "file-saver": "^2.0.5",
+    "iconv-lite": "^0.6.3",
     "js-md5": "^0.8.3",
     "qs": "^6.11.2",
     "register-service-worker": "^1.7.2",

+ 1 - 1
src/api/index.ts

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

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

@@ -1,9 +0,0 @@
-
-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", })
-

+ 4 - 0
src/api/module/printUilts.ts

@@ -0,0 +1,4 @@
+import $http from '@/utils/index'
+
+// 导出pdf
+export const inventExcel = (params: any) => $http.post('/sales/stock-out/export', params, { responseType: "blob", })

+ 7 - 0
src/api/module/sellManage.ts

@@ -13,3 +13,10 @@ export const stockunit = (params: any) => $http.post('/stock/unit/list', params)
 //批号
 export const batchnumber = (params: any) => $http.post('/medicine/batch-number', params)
 
+
+//导出销售清单-excel
+export const salesExcel = (params: any) => $http.post('/sales/excel', params, { responseType: "blob", })
+
+//导出销售报表-excel
+export const salesReportExcel = (params: any) => $http.post('/sales/report-excel', params, { responseType: "blob", })
+

+ 16 - 54
src/utils/download.ts

@@ -1,4 +1,4 @@
-
+import iconv from 'iconv-lite';
 /**
  * @author yxm 
  * @description  导出文件流
@@ -6,6 +6,8 @@
  * @param { String } paraName 文件名+后缀名
 */
 
+ 
+
 
 import $http from '@/utils/index'
 
@@ -19,62 +21,22 @@ export const getContentExportApi = (params: any) => $http.post('/stock/inquiry/e
  * @param name 下载的文件名
  * @param format 下载的文件格式  xlsx
  */
-export function downloadExcelFun(res: any, name: string, format: string) {
-  let blob = new Blob([res], { type: format == 'zip' ? 'application/zip' : 'application/x-rar-compressed' });
+export function downloadExcelFun(res: any) {
+    const fileName = decodeURIComponent(res.headers["content-disposition"])
+  let blob = new Blob([res.data], { type:'application/x-rar-compressed'});
+
   let url = window.URL.createObjectURL(blob); // 创建 url 并指向 blob
   let a = document.createElement("a");
   a.href = url;
-  a.download = `${Math.random()}.${format}`;
+  a.download = fileName.split(";")[2].split("''")[1];
   a.click();
   window.URL.revokeObjectURL(url); // 释放该 url
 }
-export function downloadFile(data:any, fileName:any, fileSuffix:any) {
-  //data是后端返回的文件流
-  let fileTypeMime = '' // 文件 mime 类型,移动端必传,否则下载不成功;pc端可传可不传
-  switch (fileSuffix) { // 获取后缀对应的 mime
-    case 'png':
-      fileTypeMime = 'image/png';
-      break;
-    case 'doc':
-      fileTypeMime = 'application/msword';
-      break;
-    case 'docx':
-      fileTypeMime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
-      break;
-    case 'jpg':
-    case 'jpeg':
-      fileTypeMime = 'image/jpeg';
-      break;
-    case 'gif':
-      fileTypeMime = 'image/gif';
-      break;
-    case 'svg':
-      fileTypeMime = 'image/svg+xml';
-      break;
-    case 'tif':
-    case 'tiff':
-      fileTypeMime = 'image/tiff';
-      break;
-    case 'txt':
-      fileTypeMime = 'text/plain';
-      break;
-    case 'ppt':
-      fileTypeMime = 'application/vnd.ms-powerpoint';
-      break;
-    case 'pptx':
-      fileTypeMime = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
-      break;
-    case 'xls':
-      fileTypeMime = 'application/vnd.ms-excel';
-      break;
-    case 'xlsx':
-      fileTypeMime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
-      break;
-    case 'zip':
-      fileTypeMime = 'application/zip';
-      break;
-    case '7z':
-      fileTypeMime = 'application/x-7z-compressed';
-      break;
-  }
-}
+
+
+//打印
+export function downPDF(result: any) {
+  let fileAddress = URL.createObjectURL(new Blob([result.data], { type: "application/pdf;charset=utf-8" }))
+  let innHtml = window.open(fileAddress, '_blank');
+  innHtml?.print();
+}

+ 3 - 17
src/utils/index.ts

@@ -51,25 +51,11 @@ class RequestHttp {
 		 * @description 响应拦截器
 		 *  服务器换返回信息 -> [拦截统一处理] -> 客户端JS获取到信息
 		 */
-		this.service.interceptors.response.use(
-			(response: AxiosResponse) => {
+		this.service.interceptors.response.use((response: AxiosResponse) => {
+			console.log('请求',response)
 				const { data } = response
-				// * 在请求结束后,并关闭请求 loading
-				// loadingInstance.close && loadingInstance.close()
-				// 无权限访问 || 登录密码错误(code == 202)
-				// if (data.Code === ResultEnum.ROLE) {
-				//   return Promise.reject(data)
-				// }
-				// * 登陆失效(code == 201)
-
 				showStatus(data)
-				// * 全局错误信息拦截(防止下载文件得时候返回数据流,没有code,直接报错)
-				// if (data.Code && data.Code !== ResultEnum.SUCCESS) {
-				// 	ElMessage.error(data.Msg)
-				// 	return Promise.reject(data)
-				// }
-				// * 成功请求(在页面上除非特殊情况,否则不用在页面处理失败逻辑)
-				return data
+				return response.data.type=='application/octet-stream'?response:data
 			},
 			async (error: AxiosError) => {
 				loadingInstance.close && loadingInstance.close()

+ 17 - 10
src/views/salesmanagement/sellManage/index.vue

@@ -22,8 +22,8 @@
         </searchAdd>
         <bg istitle="基本信息">
             <template #btn>
-                <el-button round type="primary" :icon="Download">导出销售清单</el-button>
-                <el-button round type="primary" :icon="Tickets">导出销售报表</el-button>
+                <el-button round type="primary" @click="salesExcelFun('Excel')" :icon="Download">导出销售清单</el-button>
+                <el-button round type="primary" @click="salesExcelFun('ReportExcel')" :icon="Tickets">导出销售报表</el-button>
             </template>
             <template #bg>
                 <tables ref="TableRef" :requestApi="salesList" :columns="columns" :initParam="data.initParam"></tables>
@@ -34,13 +34,24 @@
 
 <script setup lang="ts">
 import { reactive, ref, onMounted,nextTick} from 'vue'
-import { salesList,prodList,stockunit } from "@/api";
+import { salesList,prodList,stockunit,salesExcel,salesReportExcel } from "@/api";
+import {downloadExcelFun,downPDF } from "@/utils/download";
 import { Download, Tickets } from '@element-plus/icons-vue'
 import tables from "@/components/table.vue";
 import searchAdd from "@/components/searchAdd.vue";
 import bg from '@/components/bg.vue'
 const TableRef = ref()
 
+
+const salesExcelFun = async (type:any)=>{
+    let result:any
+    if(type=='Excel'){//导出销售清单
+        result = await salesExcel(data.initParam)
+    }else{//导出销售清单
+        result = await salesReportExcel(data.initParam)
+    }
+    downloadExcelFun(result)
+}
 const loading = ref(false)
 interface ListItem {
     value: string
@@ -52,7 +63,8 @@ const options = ref<ListItem[]>([])
 onMounted(async() => {
     prodListApi()
     const result:any = await stockunit({type:2,name:''})
-    list.value = result.data.list.map((item:any) => {
+    let arr = result.data.list || []
+    list.value = arr.map((item:any) => {
         return { value: item, label: item}
     })
 })
@@ -119,9 +131,4 @@ const eventFun = async ()=>{
         TableRef.value?.getTableList()
     })
 }
-</script>
-<style lang="scss">
-/* @import url(); 引入css类 */
-
-.sellManage {}
-</style>
+</script>

+ 100 - 69
src/views/salesmanagement/storageOrderGoods/down.vue

@@ -1,33 +1,44 @@
 <!--  -->
 <template>
     <div class="">
-        <el-button round type="primary" :icon="Download" @click="dialogFormVisible = true">导出打印</el-button>
-        <el-dialog v-model="dialogFormVisible" title="导出打印" :append-to-body="true" draggable width="30%">
-            <el-form :model="form">
+        <el-button round type="primary" :icon="Download" @click="dialogFormVisible = true">导出/打印</el-button>
+        <el-dialog v-model="dialogFormVisible" title="导出/打印" :append-to-body="true" draggable width="30%">
+            <el-form :model="initParam" ref="formRef">
+                <el-form-item label="下单日期" :label-width="formLabelWidth"
+                prop="date" :rules="[{ required: true, message: '必填项' }]">
+                    <el-date-picker v-model="initParam.date" type="date" value-format="YYYY-MM-DD"  clearable style="width: 100%;"/>
+                </el-form-item>
+                <el-form-item label="购货单位" :label-width="formLabelWidth"
+                prop="receivingUnit" :rules="[{ required: true, message: '必填项' }]">
+                    <el-select v-model="initParam.receivingUnit" filterable remote reserve-keyword placeholder="购货单位"
+                        :remote-method="remoteMethod" :loading="loading" clearable style="width: 100%;" @click="click2">
+                        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
+                    </el-select>
+                </el-form-item>
                 <el-form-item label="开票员" :label-width="formLabelWidth">
-                    <el-input v-model="form.name" autocomplete="off" />
+                    <el-input v-model="initParam.drawer" autocomplete="off" />
                 </el-form-item>
                 <el-form-item label="发货人" :label-width="formLabelWidth">
-                    <el-input v-model="form.name" autocomplete="off" />
+                    <el-input v-model="initParam.consigner" autocomplete="off" />
                 </el-form-item>
                 <el-form-item label="财务" :label-width="formLabelWidth">
-                    <el-input v-model="form.name" autocomplete="off" />
+                    <el-input v-model="initParam.finance" autocomplete="off" />
                 </el-form-item>
                 <el-form-item label="收货人" :label-width="formLabelWidth">
-                    <el-input v-model="form.name" autocomplete="off" />
+                    <el-input v-model="initParam.consignee" autocomplete="off" />
+                </el-form-item>
+                <el-form-item label="下载文件" :label-width="formLabelWidth">
+                    <el-radio-group v-model="initParam.type">
+                        <el-radio label="excel">excel</el-radio>
+                        <el-radio label="pdf">pdf</el-radio>
+                    </el-radio-group>
                 </el-form-item>
-                <!-- <el-form-item label="发货人" :label-width="formLabelWidth">
-                    <el-select v-model="form.region" placeholder="Please select a zone">
-                        <el-option label="Zone No.1" value="shanghai" />
-                        <el-option label="Zone No.2" value="beijing" />
-                    </el-select>
-                </el-form-item> -->
             </el-form>
             <template #footer>
                 <span class="dialog-footer">
                     <el-button @click="dialogFormVisible = false">Cancel</el-button>
-                    <el-button type="primary" @click="printFun">
-                        打印
+                    <el-button type="primary" @click="printFun(formRef)">
+                        {{initParam.type=='excel'?'立即导出':'立即打印'}}
                     </el-button>
                 </span>
             </template>
@@ -38,19 +49,39 @@
 <script lang="ts" setup>
 import * as XLSX from 'xlsx'
 import { Download } from '@element-plus/icons-vue'
-import { inventPDF,inventExcel } from "@/api";
-import { reactive, ref } from 'vue'
+import { stockunit} from "@/api";
+import { reactive, ref,onMounted} from 'vue'
+import type { FormInstance } from 'element-plus'
+import {downloadExcelFun,downPDF } from "@/utils/download";
+
+import { inventExcel} from "@/api/module/printUilts";//打印
 const dialogFormVisible = ref(false)
-const formLabelWidth = '60px'
-const form = reactive({
-    name: '',
-    region: '',
-    date1: '',
-    date2: '',
-    delivery: false,
-    type: [],
-    resource: '',
-    desc: '',
+const formLabelWidth = '80px'
+const formRef = ref<FormInstance>()
+    
+const props = defineProps({
+    initParam:{
+        type:Object,
+        default: () => { },
+    }
+})
+interface initFrom {
+    date:string,
+    receivingUnit:string,
+    drawer:string,
+    consigner: string,
+    finance: string,
+    consignee:string,
+    type: string,
+}
+const initParam = reactive<initFrom>({
+    date:'',
+    receivingUnit:'',
+    drawer: '',
+    consigner: '',
+    finance: '',
+    consignee: '',
+    type:  'excel',
 })
 
 const data: any = reactive({
@@ -58,51 +89,51 @@ const data: any = reactive({
     fileAddress: ""
 })
 //函数
-const printFun = async () => {
-    inventPDF({}).then((res) => {
-        const result: any = res
-
-        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 });
-        console.log(blob);
-        let src = window.URL.createObjectURL(blob);
-        console.log(src);
-
-        // const blob = new Blob([result], { type: "application/octet-stream" });
-        // data.imgUrl = URL.createObjectURL(blob);
-
-        let printWindow: any = window.open('', '_blank');
-
-        printWindow.document.write(`<html><head><title>打印123</title></head><body><img :src="${src}"/></body></html>`);
-        // // 执行打印操作
-        printWindow.document.close();
-        printWindow.print();
-    }).catch((error) => {
-        console.log('err', error.toString())
-    });
-    // 获取待打印的内容
-
-    // 创建一个新的窗口并加载打印内容
-
-
+const printFun = async (formEl: FormInstance | undefined) => {
+    if (!formEl) return
+    formEl.validate((valid) => {
+        if (valid) {
+            inventExcel(initParam).then((res) => {
+                const result: any = res
+                initParam.type=='excel'? downloadExcelFun(result):downPDF(result)
+            }).catch((error) => {
+                console.log('err', error.toString())
+            });
+        } else {
+            return false
+        }
+    })
+}
 
 
-    // 如果内容中有图片或其他需要一定时间加载的,请使用注释中的延时打印
-    // setTimeout(() => {
-    //   printWindow.print()
-    // }, 200)
-    // printWindow.print();
 
+onMounted(async() => {
+    const result:any = await stockunit({type:2,name:''})
+    let arr = result.data.list || []
+    list.value = arr.map((item:any) => {
+        return { value: item, label: item}
+    })
+})
+interface ListItem {
+    value: string
+    label: string
+}
+const list = ref<ListItem[]>([])
+const options = ref<ListItem[]>([])
+const click2 = async ()=>{options.value = list.value }
+const loading = ref(false)
+const remoteMethod = async(query: string) => {
+    if (query) {
+        loading.value = true
+        setTimeout(() => {
+            loading.value = false
+            options.value =  list.value.filter((item:any) => {
+                return item.label.toLowerCase().includes(query.toLowerCase())
+            })
+        }, 200)
+    } else {
+        options.value = []
+    }
 }
 </script>
 <style lang="scss">

+ 3 - 2
src/views/salesmanagement/storageOrderGoods/index.vue

@@ -16,7 +16,7 @@
         </searchAdd>
         <bg istitle="基本信息">
             <template #btn>
-                <down></down>
+                <down :initParam="data.initParam"></down>
             </template>
             <template #bg>
                 <tables ref="TableRef" :requestApi="orderList" :columns="columns" :initParam="data.initParam"></tables>
@@ -46,7 +46,8 @@ const options = ref<ListItem[]>([])
 const click2 = async ()=>{options.value = list.value }
 onMounted(async() => {
     const result:any = await stockunit({type:2,name:''})
-    list.value = result.data.list.map((item:any) => {
+    let arr = result.data.list || []
+    list.value = arr.map((item:any) => {
         return { value: item, label: item}
     })
 })

+ 3 - 3
src/views/stockcontrol/storageFrom/index.vue

@@ -116,9 +116,9 @@ onMounted(async () => {
     const result3: any = await stockunit({ type: 2 })//收发货单位
 
 
-    list1.value = findMap(result1.data.list, 'obj')
-    list2.value = findMap(result2.data.list, 'obj')
-    list3.value = findMap(result3.data.list,'map')
+    list1.value = findMap(result1.data.list || [], 'obj')
+    list2.value = findMap(result2.data.list || [], 'obj')
+    list3.value = findMap(result3.data.list || [],'map')
 
 })
 //函数

+ 1 - 1
src/views/stockcontrol/storageInquire/index.vue

@@ -66,7 +66,7 @@ import { getContentExportApi,downloadExcelFun } from "@/utils/download";
 const downloadExcel = () => {
     getContentExportApi(initParam).then((res) => {
         const result: any = res
-        downloadExcelFun(result,'库存查询','xlsx')
+        downloadExcelFun(result)
     }).catch((error) => {
         console.log('err', error.toString())
     });

+ 3 - 3
src/views/stockcontrol/storagePut/index.vue

@@ -118,9 +118,9 @@ onMounted(async () => {
     const result3: any = await stockunit({ type: 1 })//收发货单位
 
 
-    list1.value = findMap(result1.data.list, 'obj')
-    list2.value = findMap(result2.data.list, 'obj')
-    list3.value = findMap(result3.data.list,'map')
+    list1.value = findMap(result1.data.list || [], 'obj')
+    list2.value = findMap(result2.data.list || [], 'obj')
+    list3.value = findMap(result3.data.list || [],'map')
 
 })
 //函数

+ 23 - 48
src/views/stockcontrol/transmitReceive/downing.vue

@@ -1,8 +1,7 @@
 <template>
-    <el-button el-button type="primary" icon="Download" @click="showFirstissue">导出首发登记表</el-button>
-    <el-button el-button type="primary" icon="Download" @click="printFun('导出运输登记表')">导出运输登记表</el-button>
-    <el-button el-button type="primary" icon="Tickets" @click="printFun('打印运输登记表')">打印运输登记表</el-button>
-    <el-dialog v-model="dialogFormVisible" title="导出首发登记表" :append-to-body="true" draggable width="30%">
+    <el-button el-button type="primary" icon="Download" @click="dialogFormVisible = true">收发登记表</el-button>
+    <el-button el-button type="primary" icon="Download" @click="dialogFormVisible1 = true">运输登记表</el-button>
+    <el-dialog v-model="dialogFormVisible" title="收发登记表" :append-to-body="true" draggable width="30%">
         <el-form :model="initParam" ref="ruleFormRef" :rules="rules">
             <el-form-item label="疫苗名称" :label-width="formLabelWidth" prop="productId">
                 <el-select v-model.number="initParam.productId" filterable remote reserve-keyword placeholder="疫苗名称"
@@ -30,21 +29,16 @@
                     <el-option v-for="item in options5" :key="item" :label="item" :value="item" />
                 </el-select>
             </el-form-item>
-            <el-form-item label="下载文件" :label-width="formLabelWidth">
-                <el-radio-group v-model="initParam.type">
-                    <el-radio label="excel">excel</el-radio>
-                    <el-radio label="pdf">pdf</el-radio>
-                </el-radio-group>
-            </el-form-item>
         </el-form>
         <template #footer>
             <span class="dialog-footer">
                 <el-button @click="dialogFormVisible = false">Cancel</el-button>
-                <el-button type="primary" @click="submitForm(ruleFormRef)">导出</el-button>
+                <el-button type="primary" @click="submitForm(ruleFormRef,'excel')">导出</el-button>
+                <el-button type="primary" @click="submitForm(ruleFormRef,'pdf')">打印</el-button>
             </span>
         </template>
     </el-dialog>
-    <el-dialog v-model="dialogFormVisible1" :title="showTit" :append-to-body="true" draggable width="30%">
+    <el-dialog v-model="dialogFormVisible1" title="运输登记表" :append-to-body="true" draggable width="30%">
         <el-form :model="initParamWord" ref="ruleFormRef1" :rules="rules1">
             <el-form-item label="出库日期" :label-width="formLabelWidth" prop="date">
                 <el-date-picker v-model="initParamWord.date" type="date" value-format="YYYY-MM-DD" clearable
@@ -64,17 +58,13 @@
                     <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value" />
                 </el-select>
             </el-form-item>
-            <el-form-item label="下载文件" :label-width="formLabelWidth">
-                <el-radio-group v-model="initParamWord.type">
-                    <el-radio label="word">word</el-radio>
-                    <el-radio label="pdf">pdf</el-radio>
-                </el-radio-group>
-            </el-form-item>
         </el-form>
         <template #footer>
             <span class="dialog-footer">
                 <el-button @click="dialogFormVisible1 = false">Cancel</el-button>
-                <el-button type="primary" @click="submitForm1(ruleFormRef1)">提交</el-button>
+                <el-button type="primary" @click="submitForm1(ruleFormRef1,'word')">导出</el-button>
+                <el-button type="primary" @click="submitForm1(ruleFormRef1,'pdf')">打印</el-button>
+
             </span>
         </template>
     </el-dialog>
@@ -84,13 +74,12 @@
 import { inventoryExcel, transportWord } from "@/api";
 import { gradeName, enterpriseFun, stockunitFun, specification, LotNumber } from "@/plugins/selectData";
 import { reactive, ref, onMounted } from 'vue'
-import { downloadFile, downloadExcelFun } from "@/utils/download";
-import type { FormInstance, FormRules } from 'element-plus'
+import { downPDF, downloadExcelFun } from "@/utils/download";
+import type { FormInstance } from 'element-plus'
 const dialogFormVisible = ref(false)
 const dialogFormVisible1 = ref(false)
 const ruleFormRef = ref<FormInstance>()
 const ruleFormRef1 = ref<FormInstance>()
-const showTit = ref('')
 const formLabelWidth = '80px'
 const loading = ref(false)
 interface RuleForm {
@@ -105,7 +94,7 @@ const initParam = reactive<RuleForm>({//请求参数
     "enterpriseId": null,
     "productId": null,
     "specId": null,
-    "type": 'excel'
+    "type": ''
 })
 interface RuleForm1 {
     date: any,
@@ -117,7 +106,7 @@ const initParamWord = reactive<RuleForm1>({//请求参数
     "date": null,
     "receivingUnit": null,
     "productId": null,
-    "type": 'word'
+    "type": ''
 })
 onMounted(async () => {
     const result1: any = await gradeName()//疫苗名称
@@ -125,10 +114,10 @@ onMounted(async () => {
     const result3: any = await specification()//规格
     const result4: any = await stockunitFun(2)//收发货单位
 
-    list1.value = findMap(result1, 'obj')
-    list2.value = findMap(result2, 'obj')
-    list3.value = findMap(result3, 'obj')
-    list4.value = findMap(result4, 'map')
+    list1.value = findMap(result1 || [], 'obj')
+    list2.value = findMap(result2 || [], 'obj')
+    list3.value = findMap(result3 || [], 'obj')
+    list4.value = findMap(result4 || [], 'map')
 
 })
 //函数
@@ -218,22 +207,19 @@ const remoteMethod4 = async (query: string) => {
 onMounted(async () => {
     options5.value = await LotNumber()
 })
-//导出首发登记表
-const showFirstissue = async () => {
-    dialogFormVisible.value = true
-}
 const rules = reactive({
     batchNumber: [{ required: true, message: '必填项', trigger: 'change' }],
     enterpriseId: [{ required: true, message: '必填项', trigger: 'change' }],
     productId: [{ required: true, message: '必填项', trigger: 'change' }],
     specId: [{ required: true, message: '必填项', trigger: 'change' }],
 })
-const submitForm = async (formEl: FormInstance | undefined) => {
+const submitForm = async (formEl: FormInstance | undefined,ty:string) => {
     if (!formEl) return
     await formEl.validate(async (valid, fields) => {
         if (valid) {
+            initParam.type = ty
             const result = await inventoryExcel(initParam)
-            downloadExcelFun(result, '首发登记表', initParam.type=='excel'?'xlsx':'pdf')
+            ty=='excel'?downloadExcelFun(result):downPDF(result)
         } else {
             console.log('error submit!', fields)
         }
@@ -243,29 +229,18 @@ const rules1 = reactive({
     date: [{ required: true, message: '必填项', trigger: 'change' }],
     receivingUnit: [{ required: true, message: '必填项', trigger: 'change' }],
 })
-const submitForm1 = async (formEl: FormInstance | undefined) => {
+const submitForm1 = async (formEl: FormInstance | undefined,ty:any) => {
     if (!formEl) return
     await formEl.validate(async (valid, fields) => {
         if (valid) {
+            initParamWord.type = ty
             const result:any = await transportWord(initParamWord)
-            if(showTit.value=='导出运输登记表'){
-                downloadExcelFun(result, '运输登记表', initParamWord.type=='word'?'docx':'pdf')
-            }else {
-                let fileAddress = URL.createObjectURL(new Blob([result], { type: `application/${initParamWord.type=='word'?'docx':'pdf'};charset=utf-8` }))
-                let innHtml = window.open(fileAddress, '_blank');
-                innHtml?.print();
-            }
-           
+            ty=='word'?downloadExcelFun(result):downPDF(result)
         } else {
             console.log('error submit!', fields)
         }
     })
 }
-const printFun = async (tit: any) => {
-    showTit.value = tit
-    console.log('导出', initParam)
-    dialogFormVisible1.value = true
-}
 </script>
 <style lang="scss">
 /* @import url(); 引入css类 */

+ 3 - 3
src/views/stockcontrol/transmitReceive/index.vue

@@ -166,9 +166,9 @@ onMounted(async () => {
     const result2: any = await enterpriseList({ page: 1, pageSize: 999 })//生产企业
     const result3: any = await stockunit({ type: 3 })//收发货单位
 
-    list1.value = findMap(result1.data.list,'obj')
-    list2.value = findMap(result2.data.list,'obj')
-    list3.value = findMap(result3.data.list,'map')
+    list1.value = findMap(result1.data.list || [],'obj')
+    list2.value = findMap(result2.data.list || [],'obj')
+    list3.value = findMap(result3.data.list || [],'map')
 })
 //函数
 const click1 = async ()=>{options1.value = list1.value  }