【需求开发】完成模具打印相关逻辑

pull/3/head
zengchenxi 9 months ago
parent f09b4249f7
commit 09a8182079

@ -120,4 +120,12 @@ public class DeliverOrderRespVO {
@ExcelProperty("发货人姓名")
private String deliverPersonName;
@Schema(description = "制单人姓名")
@ExcelProperty("制单人姓名")
private String creatorName;
@Schema(description = "业务员姓名")
@ExcelProperty("业务员姓名")
private String businessManName;
}

@ -1,14 +1,15 @@
package com.chanko.yunxi.mes.module.heli.dal.dataobject.deliverorder;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chanko.yunxi.mes.framework.mybatis.core.dataobject.BaseDO;
import com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum;
import com.chanko.yunxi.mes.module.heli.enums.DeliverOrderStatusEnum;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.chanko.yunxi.mes.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
@ -125,6 +126,12 @@ public class DeliverOrderDO extends BaseDO {
@TableField(exist = false)
private String deliverPersonName;
@TableField(exist = false)
private String creatorName;
@TableField(exist = false)
private String businessManName;
public boolean canDeliver() {
return DeliverOrderStatusEnum.SAVE.getCode() == this.deliverStatus.intValue();
}

@ -46,12 +46,14 @@ public interface DeliverOrderMapper extends BaseMapperX<DeliverOrderDO> {
default DeliverOrderDO selectById(Long id) {
MPJLambdaWrapper<DeliverOrderDO> query = new MPJLambdaWrapper<>();
query.selectAll(DeliverOrderDO.class)
.select("u.nickname as deliverPersonName", "e.name as customerName")
.select("u.nickname as deliverPersonName", "e.name as customerName", "u1.nickname as creatorName", "u2.nickname as businessManName")
.select("GROUP_CONCAT(distinct p.code) as saleOrderCode", "GROUP_CONCAT(p.mould_name) as mouldName"
, "GROUP_CONCAT(p.contract_no) as contractNo", "GROUP_CONCAT(p.property) as property")
.leftJoin("project_sale_order p on FIND_IN_SET(p.id, t.sale_order_ids)")
.leftJoin(CustomerDO.class, "e", CustomerDO::getId, DeliverOrderDO::getCustomerId)
.leftJoin(AdminUserDO.class, "u", AdminUserDO::getId, DeliverOrderDO::getDeliverPerson)
.leftJoin(AdminUserDO.class, "u1", AdminUserDO::getId, DeliverOrderDO::getCreator)
.leftJoin("system_users u2 on u2.id = p.business_man")
.eq(DeliverOrderDO::getId, id)
.groupBy(DeliverOrderDO::getId)
.last("LIMIT 1")

@ -498,11 +498,13 @@
> </el-button>
<el-button v-if="(((active != 'detail' && formData.id) || active == 'deliver') && formData.deliverStatus == 1)" @click="submitForm('DELIVER')" type="primary" :disabled="formLoading" size="large"
> </el-button>
<el-button v-if="active == 'detail' && formData.deliverStatus == 2 && formData.id" type="primary" :disabled="formLoading" size="large"
<el-button v-if="active == 'detail' && formData.deliverStatus == 2 && formData.id" type="primary" @click="printHandle" :disabled="formLoading" size="large"
>打印发货单</el-button>
</div>
</el-card>
<ProjectOrderDialog ref="projectOrderDialog" @success="handleSelectedProjectOrder" />
<!-- 打印发货单 - 弹框-->
<ShipmentsPrint ref="shipmentsPrintRef" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
@ -526,6 +528,7 @@ import {
} from "@/api/heli/projectorder";
import {getCustomer} from "@/api/heli/customer";
import ProjectOrderDialog from "@/views/heli/deliverorder/projectOrderDialog.vue";
import ShipmentsPrint from './shipmentsPrint.vue' //
defineOptions({ name: 'DeliverOrderDetail' })
@ -581,7 +584,7 @@ const formRules = reactive({
customerId: [{ required: true, message: '客户id不能为空', trigger: 'blur' }],
deliverCompany: [{ required: true, message: '发货单位不能为空', trigger: 'blur' }],
deliverDate: [{ required: true, message: '发货日期不能为空', trigger: 'blur' }],
deliverStatus: [{ required: true, message: '发货单状态不能为空', trigger: 'change' }],
deliverStatus: [{ required: true, message: '发货单状态不能为空', trigger: 'blur' }],
deliverPerson: [{ required: true, message: '发货人不能为空', trigger: 'blur' }],
deliverPersonMobile: [{ required: true, message: '发货人电话不能为空', trigger: 'blur' }],
deliverMode: [{ required: true, message: '发货方式不能为空', trigger: 'change' }],
@ -591,11 +594,11 @@ const formRules = reactive({
})
const subFormLoading = ref(false) //
const subFormRules = reactive({
deliveryOrderId: [{ required: true, message: '订单id不能为空', trigger: 'blur' }],
subType: [{ required: true, message: '所属类型不能为空', trigger: 'change' }],
deliveryOrderId: [{ required: true, message: '订单不能为空', trigger: 'blur' }],
subType: [{ required: true, message: '所属类型不能为空', trigger: 'blur' }],
name: [{ required: true, message: '名称,唯一不能为空', trigger: 'blur' }],
amount: [{ required: true, message: '本次发货数量不能为空', trigger: 'blur' }],
unit: [{ required: true, message: '单位不能为空', trigger: 'change' }],
unit: [{ required: true, message: '单位不能为空', trigger: 'blur' }],
})
const formRef = ref() // Ref
/** 子表的表单 */
@ -780,7 +783,6 @@ const downloadAttachment = async (name, url) => {
/** 打开弹窗 */
const queryData = async (type: string, id?: number) => {
console.log(type, id)
dialogTitle.value = t('action.' + type)
//
formLoading.value = true
@ -917,6 +919,13 @@ const receiveOnChange = (val) => {
}
}
//
const shipmentsPrintRef = ref() //
const printHandle =()=> {
shipmentsPrintRef.value.open(formData.value.id)
}
const initDeliverData = async (projectOrderId) => {
let projectOrder = await getProjectOrder(projectOrderId);
handleSelectedProjectOrder([projectOrder])

@ -0,0 +1,588 @@
<template>
<Dialog title="打印预览" v-model="dialogVisible" width="1000" v-loading="formLoading">
<!-- 打印预览 -->
<div class="print-wrap page" ref="print">
<!-- 客户联 -->
<table border="2" cellspacing="0" id="table" >
<tbody>
<tr>
<td colspan="10">
<div style="display: flex; align-items: center; justify-content: space-between">
<img src="/src/assets/imgs/exlogo.png" style="width: 100px" alt="" />
<span style="font-size: 20px; font-weight: 700">发货单</span>
<span
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span
>
</div>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td colspan="2"> 发货编号 </td>
<td colspan="3">
<span>{{ formData.code }}</span>
</td>
<td>合同号</td>
<td colspan="2">{{ formData.contractNo }}</td>
<td> 性质 </td>
<td>{{ formData.property }} </td>
</tr>
</tbody>
<tr>
<td colspan="2"> 发货日期 </td>
<td colspan="3">
{{ formatDate(new Date(formData.deliverDate), 'YYYY-MM-DD') }}
</td>
<td> 联系人</td>
<td>{{ formData.businessManName }} </td>
<td> 电话 </td>
<td colspan="2">{{ formData.deliverPersonMobile }} </td>
</tr>
<tr>
<td colspan="2"> 收货单位 </td>
<td colspan="8">{{ formData.customerName }}</td>
</tr>
<tr>
<td colspan="2"> 收货地址 </td>
<td colspan="8">{{ formData.receiveAddress }}</td>
</tr>
<tr>
<td colspan="2"> 项目名称</td>
<td colspan="4">{{ formData.mouldName }}</td>
<td>重量(T)</td>
<td>{{ formData.transportWeight }}</td>
<td>位置()</td>
<td>{{ formData.transportSize }}</td>
</tr>
<tbody>
<tr>
<td colspan="4"> 内容清单 </td>
<td> 单位 </td>
<td> 数量 </td>
<td>重量(T)</td>
<td>尺寸()</td>
<td colspan="2"> 备注 </td>
</tr>
<tr v-show="subTotalAmount <= splitThreshold" v-for="(item,index) in formData.deliverOrderSubs" :key="index">
<td colspan="4">{{item.name}}</td>
<td>{{getDictLabel(DICT_TYPE.HELI_MATERIAL_UNIT, item.unit)}}</td>
<td>{{item.amount}}</td>
<td>{{item.weight}}</td>
<td>{{item.size}}</td>
<td colspan="2">{{item.remark}}</td>
</tr>
<tr v-if="subTotalAmount > splitThreshold">
<td colspan="4">工装模具详见清单附件</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="4">附光盘+各类报告</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2"></td>
</tr>
</tbody>
<tr>
<td colspan="2"> 发货单位 </td>
<td colspan="3">
{{ formData.deliverCompany }}
</td>
<td> 联系人</td>
<td>{{ formData.deliverPersonName }} </td>
<td> 电话 </td>
<td colspan="2">{{ formData.deliverPersonMobile }} </td>
</tr>
<tr>
<td colspan="2"> 司机姓名 </td>
<td colspan="2">
{{ formData.transportDriverName }}
</td>
<td>车牌号</td>
<td colspan="2">{{formData.transportBusNumber}}</td>
<td> 电话 </td>
<td colspan="2">{{ formData.transportDriverMobile }} </td>
</tr>
<tr>
<td colspan="5">
<div style="text-align: left">内部货物门点人签名:</div>
</td>
<td colspan="5">
<div style="text-align: left">收货人签名:</div>
</td>
</tr>
</table>
<div style="width: 100%; display: flex; justify-content: space-between; align-items: center">
<span>制单人{{ formData.creatorName }}</span>
<span>-客户联-</span>
</div>
<div class="divide_line" style="margin: 20px 0"></div>
<!-- 回单联 -->
<table border="2" cellspacing="0" id="table1" style="position: relative !important">
<!-- <img
src="/src/assets/imgs/exlogo.png"
style="position: absolute; top: 10px; width: 90px"
alt=""
/> -->
<tbody>
<tr>
<td colspan="10">
<div style="display: flex; align-items: center; justify-content: space-between">
<img src="/src/assets/imgs/exlogo.png" style="width: 100px" alt="" />
<span style="font-size: 20px; font-weight: 700">发货单</span>
<span
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span
>
</div>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td colspan="2"> 发货编号 </td>
<td colspan="3">
<span>{{ formData.code }}</span>
</td>
<td>合同号</td>
<td colspan="2">{{ formData.contractNo }}</td>
<td> 性质 </td>
<td>{{ formData.property }} </td>
</tr>
</tbody>
<tr>
<td colspan="2"> 发货日期 </td>
<td colspan="3">
{{ formatDate(new Date(formData.deliverDate), 'YYYY-MM-DD') }}
</td>
<td> 联系人</td>
<td>{{ formData.businessManName }} </td>
<td> 电话 </td>
<td colspan="2">{{ formData.deliverPersonMobile }} </td>
</tr>
<tr>
<td colspan="2"> 收货单位 </td>
<td colspan="8">{{ formData.customerName }}</td>
</tr>
<tr>
<td colspan="2"> 收货地址 </td>
<td colspan="8">{{ formData.receiveAddress }}</td>
</tr>
<tr>
<td colspan="2"> 项目名称</td>
<td colspan="4">{{ formData.mouldName }}</td>
<td>重量(T)</td>
<td>{{ formData.transportWeight }}</td>
<td>位置()</td>
<td>{{ formData.transportSize }}</td>
</tr>
<tbody>
<tr>
<td colspan="4"> 内容清单 </td>
<td> 单位 </td>
<td> 数量 </td>
<td>重量(T)</td>
<td>尺寸()</td>
<td colspan="2"> 备注 </td>
</tr>
<tr v-show="subTotalAmount <= splitThreshold" v-for="(item,index) in formData.deliverOrderSubs" :key="index">
<td colspan="4">{{item.name}}</td>
<td>{{getDictLabel(DICT_TYPE.HELI_MATERIAL_UNIT, item.unit)}}</td>
<td>{{item.amount}}</td>
<td>{{item.weight}}</td>
<td>{{item.size}}</td>
<td colspan="2">{{item.remark}}</td>
</tr>
<tr v-if="subTotalAmount > splitThreshold">
<td colspan="4">工装模具详见清单附件</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="4">附光盘+各类报告</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2"></td>
</tr>
</tbody>
<tr>
<td colspan="2"> 发货单位 </td>
<td colspan="3">
{{ formData.deliverCompany }}
</td>
<td> 联系人</td>
<td>{{ formData.deliverPersonName }} </td>
<td> 电话 </td>
<td colspan="2">{{ formData.deliverPersonMobile }} </td>
</tr>
<tr>
<td colspan="2"> 司机姓名 </td>
<td colspan="2">
{{ formData.transportDriverName }}
</td>
<td>车牌号</td>
<td colspan="2">{{formData.transportBusNumber}}</td>
<td> 电话 </td>
<td colspan="2">{{ formData.transportDriverMobile }} </td>
</tr>
<tr>
<td colspan="5">
<div style="text-align: left">内部货物门点人签名:</div>
</td>
<td colspan="5">
<div style="text-align: left">收货人签名:</div>
</td>
</tr>
</table>
<div
style="
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
"
>
<span>制单人{{ formData.creatorName }}</span>
<span>-回单联-</span>
</div>
<!-- 附件 -->
<!-- 附件需要判断 -->
<div v-if="subTotalAmount > splitThreshold">
<div class="divide_line1" style="margin-top: 30px"></div>
<table border="2" cellspacing="0" id="table1" style="height: 28cm; ">
<tbody>
<tr>
<td colspan="10">
<div style="display: flex; align-items: center; justify-content: space-between">
<img src="/src/assets/imgs/exlogo.png" style="width: 100px" alt="" />
<span style="font-size: 20px; font-weight: 700">清单附件</span>
<span style="font-size: 12px">发货编号{{ formData.code }}</span>
</div>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td> 序号 </td>
<td colspan="3">
<span>摸具名称</span>
</td>
<td colspan="3">摸具图号</td>
<td> 数量() </td>
<td colspan="2">备注 </td>
</tr>
<tr>
<td colspan="10" style="background-color: rgb(255, 255, 0)">
<div style="text-align: left">模具清单</div>
</td>
</tr>
<tr v-for="(item,index) in formData.deliverOrderSubs" :key="index">
<td> {{ index+1 }} </td>
<td colspan="3">{{ item.name }}</td>
<td colspan="3">{{ item.blueprintNo}}</td>
<td> {{ item.amount }} </td>
<td colspan="2">{{ item.remark }} </td>
</tr>
<tr>
<td colspan="10" style="background-color: rgb(255, 255, 0)">
<div style="text-align: left">备件清单</div>
</td>
</tr>
<tr v-for="(item, index) in formData.deliverOrderOtherSpareSubs" :key="index">
<td> {{ index+1 }} </td>
<td colspan="3">
<span>{{ item.name }}</span>
</td>
<td colspan="3">{{ item.blueprintNo}}</td>
<td> {{ item.amount }} </td>
<td colspan="2">{{ item.remark }} </td>
</tr>
<tr>
<td colspan="10" style="background-color: rgb(255, 255, 0)">
<div style="text-align: left">刀具清单</div>
</td>
</tr>
<tr v-for="(item, index) in formData.deliverOrderOtherCutterSubs" :key="index">
<td> {{ index+1 }} </td>
<td colspan="3">
<span>{{ item.name }}</span>
</td>
<td colspan="3">{{ item.blueprintNo}}</td>
<td> {{ item.amount }} </td>
<td colspan="2">{{ item.remark }} </td>
</tr>
</tbody>
<tr>
<td colspan="10">
<div style="text-align: left">内部货物门点人签名:</div>
</td>
</tr>
</table>
<div
style="
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
"
>
<span>制单人{{ formData.creatorName }}</span>
<span>-回单联-</span>
</div>
</div>
</div>
<template #footer>
<!-- 打印 -->
<el-button @click="onPrint" type="primary">打印</el-button>
<el-button @click="outopen"></el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
// import { ref, reactive } from 'vue'
import { Check } from '@element-plus/icons-vue'
import {ref} from "vue";
import {getDictLabel, DICT_TYPE} from "@/utils/dict";
import {getDeliverOrder, getDeliverOrderSubListByDeliveryOrderId} from "@/api/heli/deliverorder";
import {formatDate} from "@/utils/formatTime";
const dialogVisible = ref(false) //
const onPrint = () => {
// dom
const printNode = document.querySelector('.print-wrap')
if (!printNode) return
//
const newIframe: any = document.createElement('iframe')
newIframe.setAttribute(
'style',
'width:0px;height:0px;position:absolute;left:-9999px;top:-9999px;'
)
newIframe.setAttribute('align', 'center')
document.body.appendChild(newIframe)
//
let doc: any = null
doc = newIframe.contentWindow.document
doc.write(`
<style type="text/css">
/* 浏览器打印基本样式 */
.page {
width: 21cm;
min-height: 29.7cm;
padding: 10mm;
margin: 20px auto;
border: 1px #d3d3d3 solid;
border-radius: 5px;
background: white;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
position: relative;
font-size: 14px !important;
}
@page {
size: A4;
margin: 5px 1cm;
}
@media print {
.page {
margin: 0;
border: initial;
border-radius: initial;
width: initial;
min-height: initial;
box-shadow: initial;
background: initial;
page-break-after: always;
}
}
table {
width: 100%; /* 让表格宽度100%占满其父元素宽度 */
height: auto; /* 高度根据内容自适应 */
font-size: 14px;
text-align: center;
border-collapse: collapse;
margin-top: 5mm; /* 添加顶部外边距,替代原先的页内边距 */
td {
padding: 5px 0;
border: 1px solid #333;
}
}
.divide_line {
justify-content: center;
border-bottom: 1px dashed rgba(51, 51, 51, 1);
}
.divide_line1 {
justify-content: center;
border-bottom: 1px dashed rgb(255, 255, 255);
}
</style>
<div>
${printNode.innerHTML}
</div>`)
doc.close()
//
setTimeout(() => {
newIframe.contentWindow.focus()
newIframe.contentWindow.print()
document.body.removeChild(newIframe) //
dialogVisible.value = false
}, 100)
}
const outopen = () => {
dialogVisible.value = false
}
const queryParams: any = ref({
code: undefined
})
const formLoading = ref(false)
const formData = ref({
id: undefined,
code: undefined,
saleOrderIds: undefined,
saleOrderCode: undefined,
contractNo: undefined,
property: undefined,
customerId: undefined,
customerName: undefined,
mouldName: undefined,
deliverDate: undefined,
deliverStatus: 1,
deliverPerson: undefined,
deliverPersonName: undefined,
deliverPersonMobile: undefined,
deliverMode: undefined,
receivePersonMobile: undefined,
transportDriverName: undefined,
transportDriverMobile: undefined,
transportBusNumber: undefined,
transportWeight: undefined,
transportSize: undefined,
remark: undefined,
status: 1,
receivePersonName: undefined,
receiveAddress: undefined,
deliverOrderSubs: [],
deliverOrderOtherSubs: [],
deliverOrderOtherSpareSubs: [],
deliverOrderOtherCutterSubs: [],
attachments: [],
operateLogs: [],
active: undefined,
deliverCompany: '杭州合立机械有限公司'
})
const subTotalAmount = ref(0)
const splitThreshold = 5
/** 打开弹窗 */
const open = async (id: number) => {
dialogVisible.value = true
//
formLoading.value = true
try {
formData.value = await getDeliverOrder(id)
formData.value.deliverCompany = '杭州合立机械有限公司'
//
let properties = formData.value.property.split(",")
let property = "";
for (let i = 0; i < properties.length; i++) {
property += getDictLabel(DICT_TYPE.HELI_PROJECT_PROPERTY, properties[i]) + ",";
}
formData.value.property = property.substring(0, property.length-1);
//
const subArr = await getDeliverOrderSubListByDeliveryOrderId(id)
subTotalAmount.value = subArr.length
if(subTotalAmount.value > splitThreshold){
formData.value.deliverOrderSubs = subArr.filter(sub => sub.category == 'DELIVER_LIST');
//
formData.value.deliverOrderOtherSpareSubs = subArr.filter(sub => (sub.category == 'OTHER_LIST' && sub.subType == 1 ));
formData.value.deliverOrderOtherCutterSubs = subArr.filter(sub => (sub.category == 'OTHER_LIST' && sub.subType == 2 ));
}else{
formData.value.deliverOrderSubs = subArr
}
} finally {
formLoading.value = false
}
}
defineExpose({ open }) // open
</script>
<style scoped lang="scss">
.page {
width: 21cm;
min-height: 29.7cm;
padding: 10mm;
margin: 20px auto;
border: 1px #d3d3d3 solid;
border-radius: 5px;
background: white;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
position: relative;
font-size: 14px !important;
}
@page {
size: A4;
margin: 0;
}
@media print {
.page {
margin: 0;
border: initial;
border-radius: initial;
width: initial;
min-height: initial;
box-shadow: initial;
background: initial;
page-break-after: always;
}
}
table {
width: 100%; /* 让表格宽度100%占满其父元素宽度 */
height: auto; /* 高度根据内容自适应 */
font-size: 14px;
text-align: center;
border-collapse: collapse;
margin-top: 5mm; /* 添加顶部外边距,替代原先的页内边距 */
td {
padding: 5px 0;
border: 1px solid #333;
}
}
.divide_line {
justify-content: center;
border-bottom: 1px dashed rgba(51, 51, 51, 1);
}
.divide_line1 {
justify-content: center;
border-bottom: 1px dashed rgb(255, 255, 255);
}
#table {
position: relative;
}
/*
A4的大小21cm*29.7cmwidth:794px;
单位换算1 inch = 2.54 cm 1mm = 96 px 1 cm = 37.79528 px*/
</style>

@ -314,7 +314,7 @@ const formData = ref({
approveUserName: undefined
})
/** 打开弹窗 */
const open = async (id?: number) => {
const open = async (id: number) => {
dialogVisible.value = true
resetForm()
formData.value = await ProjectOrderApi.getProjectOrder(id)

Loading…
Cancel
Save