YangJian0701 1 year ago
parent
commit
2a48d5c0eb

+ 2 - 1
src/api/module/sellManage.ts

@@ -10,5 +10,6 @@ export const prodList = (params: any) => $http.post('/product/list', params)
 //购货单位
 export const stockunit = (params: any) => $http.post('/stock/unit/list', params)
 
-
+//批号
+export const batchnumber = (params: any) => $http.post('/medicine/batch-number', params)
 

+ 6 - 2
src/api/module/transmitReceive.ts

@@ -5,8 +5,12 @@ import $http from '@/utils/index'
 
 // 收发记录-列表
 export const inventoryList = (params: any) => $http.post('/stock-template/inventory/list', params)
-// // 品种
-// export const prodList = (params: any) => $http.post('/product/list', params)
+// 收发记录-excel
+export const inventoryExcel = (params: any) => $http.post('/stock-template/inventory/export', params, { responseType: "blob", })
+// 运输-excel
+export const transportWord = (params: any) => $http.post('/stock-template/transport-record/export', params, { responseType: "blob", })
+
+
 // //购货单位
 // export const stockunit = (params: any) => $http.post('/stock/unit/list', params)
 

+ 2 - 1
src/plugins/rulesData.ts

@@ -23,6 +23,7 @@ export let columnsTable = [
     { prop: 'operator', label: '经办人', width: 0 },
     { prop: 'forwardingUnit', label: '发货单位', width: 0 },
     { prop: 'date', label: '入库日期', width: 0 },
+    { prop: 'operation', label: '操作', fixed: 'right',"min-width":200}
 ]
 
 //出库
@@ -32,5 +33,5 @@ export let columnsTableOut = [
     { label: '经办人', prop: 'operator', width: 0 },
     { label: '收货单位', prop: 'receivingUnit', width: 0 },
     { label: '出库日期', prop: 'date', width: 0 },
-
+    { prop: 'operation', label: '操作', fixed: 'right',"min-width":200}
 ]

+ 54 - 0
src/plugins/selectData.ts

@@ -0,0 +1,54 @@
+import {
+    inventoryList,
+    productList,//疫苗名称
+    enterpriseList,//生产企业
+    stockunit,//收发货单位 2收货,3发货
+    specList,//规格
+    batchnumber,//批号
+} from "@/api";
+
+
+/**
+ * 批号
+ * @param params 
+ */
+export async function LotNumber() {
+    const reslut:any =await batchnumber({})
+    return reslut.data
+}
+
+/**
+ * 规格
+ */
+export async function specification(){
+    const reslut:any =await specList({ page: 1, pageSize: 999 })
+    return reslut.data.list
+}
+/**
+ * 品名(疫苗名称)
+ */
+export async function gradeName(){
+    const reslut:any =await productList({ page: 1, pageSize: 999 })
+    return reslut.data.list
+}
+
+/**
+ * 单位
+ */
+export function unitFun(){
+
+}
+/**
+ * 生产企业
+ */
+export async function enterpriseFun(){
+    const reslut:any =await enterpriseList({ page: 1, pageSize: 999 })
+    return reslut.data.list
+}
+/**
+ * 收发货单位 2收货,3发货
+ */
+export async function stockunitFun(type:any){
+    const reslut:any =await stockunit({ type: type })
+    return reslut.data.list
+}

+ 54 - 4
src/utils/download.ts

@@ -19,12 +19,62 @@ 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]);
+export function downloadExcelFun(res: any, name: string, format: string) {
+  let blob = new Blob([res], { type: format == 'zip' ? 'application/zip' : 'application/x-rar-compressed' });
   let url = window.URL.createObjectURL(blob); // 创建 url 并指向 blob
   let a = document.createElement("a");
   a.href = url;
-  a.download = `${name}.${format}`;
+  a.download = `${Math.random()}.${format}`;
   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;
+  }
+}

+ 0 - 3
src/views/salesmanagement/storageOrderGoods/down.vue

@@ -1,8 +1,6 @@
 <!--  -->
 <template>
     <div class="">
-        <div id="printable">
-        </div>
         <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">
@@ -34,7 +32,6 @@
                 </span>
             </template>
         </el-dialog>
-        {{ data.fileAddress }}
     </div>
 </template>
 

+ 4 - 0
src/views/stockcontrol/storageFrom/index.vue

@@ -40,6 +40,10 @@
             </template>
             <template #bg>
                 <tables ref="TableRef" :requestApi="stockOutList" :columns="columns" :initParam="initParam">
+                    <template #right="{ row }">
+                        <el-button type="primary">编辑</el-button>
+                        <el-button type="danger">删除</el-button>
+                    </template>
                 </tables>
             </template>
         </bg>

+ 1 - 0
src/views/stockcontrol/storageFrom/scanCode.vue

@@ -95,6 +95,7 @@ const innerVisible = ref(false)
 import { ElMessage, ElMessageBox } from 'element-plus'
 import {Delete,Edit,} from '@element-plus/icons-vue'
 const formLabelWidth = '110px'
+
 let initParam:any = reactive({
     "date": "",
     "forwardingUnit": "",

+ 9 - 0
src/views/stockcontrol/storagePut/index.vue

@@ -40,6 +40,10 @@
             </template>
             <template #bg>
                 <tables ref="TableRef" :requestApi="stockInList" :columns="columns" :initParam="initParam">
+                    <template #right="{ row }">
+                        <el-button type="primary" @click="editFun(row)">编辑</el-button>
+                        <el-button type="danger">删除</el-button>
+                    </template>
                 </tables>
             </template>
         </bg>
@@ -61,7 +65,12 @@ import bg from '@/components/bg.vue'
 import scanCode from './scanCode.vue'
 const TableRef = ref()
 import { syrulesData,columnsTable } from "@/plugins/rulesData";
+
 //函数
+const editFun = async (row:any)=>{
+    console.log('编辑',row)
+}
+
 const scanCodeFun = async ()=>{
     console.log('添加完成')
     TableRef.value?.getTableList()

+ 272 - 0
src/views/stockcontrol/transmitReceive/downing.vue

@@ -0,0 +1,272 @@
+<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-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="疫苗名称"
+                    :remote-method="remoteMethod1" :loading="loading" clearable style="width: 100%;"
+                    @clear="initParam.productId = null" @click="click1">
+                    <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" prop="enterpriseId">
+                <el-select v-model.number="initParam.enterpriseId" filterable remote reserve-keyword placeholder="疫苗名称"
+                    :remote-method="remoteMethod2" :loading="loading" clearable style="width: 100%;"
+                    @clear="initParam.enterpriseId = null" @click="click2">
+                    <el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value" />
+                </el-select>
+            </el-form-item>
+            <el-form-item label="规格" :label-width="formLabelWidth" prop="specId">
+                <el-select v-model.number="initParam.specId" filterable remote reserve-keyword placeholder="疫苗名称"
+                    :remote-method="remoteMethod3" :loading="loading" clearable style="width: 100%;"
+                    @clear="initParam.specId = null" @click="click3">
+                    <el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value" />
+                </el-select>
+            </el-form-item>
+            <el-form-item label="批号" :label-width="formLabelWidth" prop="batchNumber">
+                <el-select v-model="initParam.batchNumber" class="m-2" placeholder="Select" style="width: 100%;">
+                    <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>
+            </span>
+        </template>
+    </el-dialog>
+    <el-dialog v-model="dialogFormVisible1" :title="showTit" :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
+                    style="width: 100%;" />
+            </el-form-item>
+            <el-form-item label="收货单位" :label-width="formLabelWidth" prop="receivingUnit">
+                <el-select v-model.number="initParamWord.receivingUnit" filterable remote reserve-keyword placeholder="疫苗名称"
+                    :remote-method="remoteMethod4" :loading="loading" clearable style="width: 100%;"
+                    @clear="initParamWord.receivingUnit = null" @click="click4">
+                    <el-option v-for="item in options4" :key="item.value" :label="item.label" :value="item.value" />
+                </el-select>
+            </el-form-item>
+            <el-form-item label="疫苗名称" :label-width="formLabelWidth">
+                <el-select v-model.number="initParamWord.productId" filterable remote reserve-keyword placeholder="疫苗名称"
+                    :remote-method="remoteMethod1" :loading="loading" clearable style="width: 100%;"
+                    @clear="initParamWord.productId = null" @click="click1">
+                    <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>
+            </span>
+        </template>
+    </el-dialog>
+</template>
+
+<script setup lang="ts">
+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'
+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 {
+    batchNumber: any,
+    enterpriseId?: any,
+    productId?: any,
+    specId: any,
+    type: string
+}
+const initParam = reactive<RuleForm>({//请求参数
+    "batchNumber": null,
+    "enterpriseId": null,
+    "productId": null,
+    "specId": null,
+    "type": 'excel'
+})
+interface RuleForm1 {
+    date: any,
+    receivingUnit?: any,
+    productId?: any,
+    type: string
+}
+const initParamWord = reactive<RuleForm1>({//请求参数
+    "date": null,
+    "receivingUnit": null,
+    "productId": null,
+    "type": 'word'
+})
+onMounted(async () => {
+    const result1: any = await gradeName()//疫苗名称
+    const result2: any = await enterpriseFun()//生产企业
+    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')
+
+})
+//函数
+const findMap = (arr: any, obj: any) => {
+    return arr.map((item: any) => {
+        return { value: obj == 'obj' ? item.id : item, label: obj == 'obj' ? item.name : item }
+    })
+}
+interface ListItem {
+    value: string
+    label: string
+}
+
+const click1 = async () => { options1.value = list1.value }
+const click2 = async () => { options2.value = list2.value }
+const click3 = async () => { options3.value = list3.value }
+const click4 = async () => { options4.value = list4.value }
+
+
+const list1 = ref<ListItem[]>([])//疫苗名称
+const list2 = ref<ListItem[]>([])//生产企业
+const list3 = ref<ListItem[]>([])//收发货单位
+const list4 = ref<ListItem[]>([])//收发货单位
+
+
+const options1 = ref<ListItem[]>([])
+const options2 = ref<ListItem[]>([])
+const options3 = ref<ListItem[]>([])
+const options4 = ref<ListItem[]>([])
+const options5 = ref<ListItem[]>([])
+
+
+
+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 remoteMethod2 = async (query: string) => {
+    if (query) {
+        loading.value = true
+        setTimeout(() => {
+            loading.value = false
+            options2.value = list2.value.filter((item: any) => {
+                console.log('第一个', query, item)
+                return item.label.toLowerCase().includes(query.toLowerCase())
+            })
+        }, 200)
+    } else {
+        options2.value = []
+    }
+}
+const remoteMethod3 = async (query: string) => {
+    if (query) {
+        loading.value = true
+        setTimeout(() => {
+            loading.value = false
+            options3.value = list3.value.filter((item: any) => {
+                return item.label.toLowerCase().includes(query.toLowerCase())
+            })
+        }, 200)
+    } else {
+        options3.value = []
+    }
+}
+const remoteMethod4 = async (query: string) => {
+    if (query) {
+        loading.value = true
+        setTimeout(() => {
+            loading.value = false
+            options4.value = list4.value.filter((item: any) => {
+                return item.label.toLowerCase().includes(query.toLowerCase())
+            })
+        }, 200)
+    } else {
+        options3.value = []
+    }
+}
+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) => {
+    if (!formEl) return
+    await formEl.validate(async (valid, fields) => {
+        if (valid) {
+            const result = await inventoryExcel(initParam)
+            downloadExcelFun(result, '首发登记表', initParam.type=='excel'?'xlsx':'pdf')
+        } else {
+            console.log('error submit!', fields)
+        }
+    })
+}
+const rules1 = reactive({
+    date: [{ required: true, message: '必填项', trigger: 'change' }],
+    receivingUnit: [{ required: true, message: '必填项', trigger: 'change' }],
+})
+const submitForm1 = async (formEl: FormInstance | undefined) => {
+    if (!formEl) return
+    await formEl.validate(async (valid, fields) => {
+        if (valid) {
+            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();
+            }
+           
+        } 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类 */
+</style>

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

@@ -32,8 +32,7 @@
         </searchAdd>
         <bg istitle="基本信息">
             <template #btn>
-                <el-button el-button type="primary" icon="Download">导出</el-button>
-                <el-button el-button type="primary" icon="Tickets" @click="printFun">打印</el-button>
+                <downing></downing>
             </template>
             <template #bg>
                 <el-table ref="multipleTableRef" :data="data.tableData" style="width: 100%"
@@ -67,6 +66,7 @@ import {
     enterpriseList,//生产企业
     stockunit,//收发货单位
 } from "@/api";
+import downing from "./downing.vue";
 import { reactive, ref, onMounted } from "vue";
 import searchAdd from "@/components/searchAdd.vue";
 import bg from '@/components/bg.vue'
@@ -126,7 +126,7 @@ const columns: any = [
     { prop: 'forwarding_unit', label: '发货单位', width: 150 },
     { prop: 'receiving_unit', label: '收货单位', width:150 },
     { prop: 'date', label: '日期', width:120},
-    { prop: 'operation', label: '操作', fixed: 'right'}
+    // { prop: 'operation', label: '操作', fixed: 'right'}
 ]
 const userListApi = async () => {
     const result: any = await inventoryList(initParam)
@@ -162,8 +162,8 @@ interface ListItem {
     label: string
 }
 onMounted(async () => {
-    const result1: any = await productList({ age: 1, pageSize: 999 })//疫苗名称
-    const result2: any = await enterpriseList({ age: 1, pageSize: 999 })//生产企业
+    const result1: any = await productList({ page: 1, pageSize: 999 })//疫苗名称
+    const result2: any = await enterpriseList({ page: 1, pageSize: 999 })//生产企业
     const result3: any = await stockunit({ type: 3 })//收发货单位
 
     list1.value = findMap(result1.data.list,'obj')