|
@@ -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类 */
|