<script setup>
|
import request from "@/utils/request"
|
import {computed, onMounted, ref, watch} from "vue"
|
import PrintFoot from "@/components/sd/order/PrintFoot.vue"
|
import companyInfo from "@/stores/sd/companyInfo"
|
import deepClone from "@/utils/deepClone";
|
import {ElMessage} from "element-plus";
|
import {add,addAuto} from '@/utils/decimal';
|
|
const company = companyInfo()
|
let produceList = ref([])
|
let otherMoney = []
|
let otherMoney1 = []
|
let delivery = ref([])
|
let money = ref("")
|
let otherMoneys = 0
|
let sumMoney = 0
|
let takeCare =ref("具体规格详见清单")
|
let remark =ref(company.deliveryRemark)
|
|
|
|
let props = defineProps({
|
deliveryId:null,
|
type:null,
|
optionVal:4
|
})
|
const form = ref({
|
})
|
let produceList2 = ref([])
|
|
watch(()=>props.optionVal,()=>{
|
//给数据进行分页
|
pageData.value = groupArrayByFive(produceList2.value[0].data)
|
delivery.value = produceList2.value[0].delivery
|
})
|
|
|
const deliveryId = ref()
|
|
const pageData = ref()
|
const getData = () => {
|
if(props.deliveryId===null || props.deliveryId===undefined || props.deliveryId===''){
|
return
|
}
|
deliveryId.value = props.deliveryId[0].deliveryId
|
form.value.deliveryId=props.deliveryId
|
form.value.type=company.productName
|
form.value.state=props.type
|
|
|
request.post(`/delivery/getSelectDeliveryPrinting`,form.value).then((res) => {
|
if(res.code==200){
|
produceList.value = deepClone(res.data)
|
for(let i=0;i<produceList.value.length;i++){
|
produceList.value[i].data.forEach(item =>{
|
let para =
|
item.DeliveryDetail.orderId=
|
`${takeCare.value}\n${item.DeliveryDetail.orderDetail.edgingType || item.DeliveryDetail.orderDetail.shape}`
|
|
})
|
let produceList1= ({
|
data:null,
|
otherMoney:null,
|
otherMoney1:null,
|
delivery:null,
|
money:null,
|
otherMoneys:0,
|
sumMoney:0
|
})
|
produceList1.data=produceList.value[i].data
|
produceList1.delivery=produceList.value[i].delivery
|
produceList1.money=produceList.value[i].money
|
produceList1.otherMoney=produceList.value[i].otherMoney
|
for(let j=0;j<produceList1.data.length;j++){
|
produceList1.sumMoney+=produceList1.data[j].DeliveryDetail.money
|
}
|
otherMoney1=[]
|
for(let i=0;i<produceList1.otherMoney.length;i++){
|
if(produceList1.otherMoney[i].DeliveryDetailOtherMoney.monery!=null){
|
produceList1.otherMoneys+=produceList1.otherMoney[i].DeliveryDetailOtherMoney.monery
|
if(otherMoney1.length===0){
|
otherMoney1.push(produceList1.otherMoney[i])
|
}
|
else{
|
for(let s=0;s<otherMoney1.length;s++){
|
if(produceList1.otherMoney[i].DeliveryDetailOtherMoney.alias===otherMoney1[s].DeliveryDetailOtherMoney.alias){
|
|
otherMoney1[s].DeliveryDetailOtherMoney.count=add(produceList1.otherMoney[i].DeliveryDetailOtherMoney.count,otherMoney1[s].DeliveryDetailOtherMoney.count)
|
otherMoney1[s].DeliveryDetailOtherMoney.monery =add(produceList1.otherMoney[i].DeliveryDetailOtherMoney.monery,otherMoney1[s].DeliveryDetailOtherMoney.monery)
|
break
|
}
|
if(s+1===otherMoney1.length){
|
otherMoney1.push(produceList1.otherMoney[i])
|
break
|
}
|
}
|
|
}
|
|
}
|
|
}
|
produceList1.otherMoney1=otherMoney1
|
produceList2.value.push(produceList1)
|
}
|
for(let j=0;j<produceList2.value.length;j++){
|
|
if(produceList2.value[j].delivery.money.toFixed(0)!==(produceList2.value[j].otherMoneys
|
+produceList2.value[j].sumMoney+produceList2.value[j].delivery.freight).toFixed(0)){
|
console.log(produceList2.value[j])
|
console.log(produceList2.value[j].delivery.money)
|
console.log((produceList2.value[j].otherMoneys
|
+produceList2.value[j].sumMoney).toFixed(0))
|
console.log(produceList2.value[j].delivery.deliveryId)
|
}
|
|
}
|
//给数据进行分页
|
pageData.value = groupArrayByFive(produceList2.value[0].data)
|
delivery.value = produceList2.value[0].delivery
|
|
|
|
}else{
|
ElMessage.warning(res.msg)
|
router.push("/login")
|
}
|
})
|
}
|
|
function groupArrayByFive(arr) {
|
let result = [];
|
if(props.optionVal === null){
|
props.optionVal = 4
|
}
|
for (let i = 0; i < arr.length; i += props.optionVal) {
|
result.push(arr.slice(i, i + props.optionVal));
|
}
|
return result;
|
}
|
let deliveryDate = ref()
|
onMounted(() => {
|
const today = new Date
|
today.setTime(today.getTime())
|
deliveryDate.value = today.getFullYear() +
|
'-' + ("0" + (today.getMonth() + 1)).slice(-2)
|
+ '-' + ("0" + today.getDate()).slice(-2)
|
getData()
|
})
|
|
const stringToJson = (productList) => {
|
productList.forEach(item => {
|
item.otherColumns = JSON.parse(item.otherColumns)
|
})
|
}
|
|
const getQuantity = (productList) => {
|
let quantity = 0
|
productList.forEach(item => {
|
quantity += item.quantity
|
})
|
return parseFloat(quantity.toFixed(3))
|
|
}
|
|
const getArea = (productList) => {
|
let area = 0
|
productList.forEach(item => {
|
area += item.grossArea
|
})
|
return parseFloat(area.toFixed(3))
|
|
}
|
|
const getPerimeter = (productList) => {
|
let perimeter = 0
|
productList.forEach(item => {
|
perimeter += item.perimeter
|
})
|
return parseFloat(perimeter.toFixed(3))
|
}
|
|
const printSheet = () => {
|
}
|
let companyName = ref('洛阳玻璃公司')
|
|
const getQuantitySum = (page)=>{
|
console.log(page)
|
if(pageData.value[page] === undefined){
|
return 0
|
}
|
return pageData.value[page].reduce((accumulator, currentValue) => {
|
return add(accumulator,currentValue.DeliveryDetail.quantity)
|
}, 0)
|
}
|
const getAreaSum = (page)=>{
|
if(pageData.value[page] === undefined){
|
return 0
|
}
|
return pageData.value[page].reduce((accumulator, currentValue) => {
|
return addAuto(accumulator,currentValue.DeliveryDetail.area,2)
|
}, 0)
|
}
|
const getMoneySum = (page)=>{
|
if(pageData.value[page] === undefined){
|
return ''
|
}
|
const val = pageData.value[page].reduce((accumulator, currentValue) => {
|
return addAuto(accumulator,currentValue.DeliveryDetail.money,2)
|
}, 0)
|
|
return val==0?'':val
|
}
|
|
|
defineExpose({
|
printSheet
|
});
|
</script>
|
|
<template>
|
<div >
|
<div v-for="(page,pageIndex) in pageData" class="content1" >
|
<table>
|
<thead>
|
<tr style="height: 3.6cm"><td></td></tr>
|
|
<tr>
|
<td colspan="6" >
|
<el-row :gutter="20">
|
<el-col :span="2"></el-col>
|
<el-col :span="8">
|
<input v-model="companyName"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:19px;font-weight: bold "/>
|
</el-col>
|
<el-col :span="6" style="font-size:19px;font-weight: bold"> {{deliveryId}} </el-col>
|
<el-col :span="3"></el-col>
|
<el-col :span="5" style="white-space: nowrap;font-size:19px;font-weight: bold">
|
<input v-model="deliveryDate"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:19px;font-weight: bold;white-space: nowrap; "/>
|
|
</el-col>
|
</el-row>
|
</td>
|
</tr>
|
<tr style="height: 0.1cm"><td></td></tr>
|
|
<tr style="margin-top: 20px">
|
<td colspan="6">
|
<el-row :gutter="20">
|
<el-col :span="2"></el-col>
|
<el-col :span="12" style="font-size: 16px;">
|
<input v-model="delivery.customerName"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:16px;white-space: nowrap; "/>
|
</el-col>
|
|
<el-col :span="10" style="font-size: 16px;white-space: nowrap;">
|
<input v-model="delivery.project"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:16px;white-space: nowrap; "/>
|
</el-col>
|
</el-row>
|
</td>
|
</tr>
|
<tr>
|
<td colspan="6">
|
<el-row :gutter="20">
|
<el-col :span="2"></el-col>
|
<el-col :span="12" style="font-size: 16px"> {{delivery.orderId }}</el-col>
|
</el-row>
|
</td>
|
</tr>
|
|
<tr style="height: 1cm"><td></td></tr>
|
|
|
|
</thead>
|
<tbody >
|
<tr v-for="(item,index) in page">
|
<td style="width: 5cm">
|
<el-input class="textarea bbb" type="textarea"
|
:autosize="{ minRows: 1, maxRows: 20 }"
|
v-model="item.DeliveryDetail.orderDetail.productName" />
|
</td>
|
|
<td style="width: 150px" >
|
<el-input class="textarea aaa" type="textarea"
|
:autosize="{ minRows: 1, maxRows: 20 }"
|
v-model="item.DeliveryDetail.orderId" />
|
|
</td>
|
<td style="width: 65px">
|
{{item.DeliveryDetail.quantity}}
|
</td>
|
<td style="width: 100px" >
|
<input style="border: 0;width: 100px" v-model="item.DeliveryDetail.area">
|
</td>
|
|
<td
|
style="width: 80px"
|
>
|
<input
|
v-if="props.type===1"
|
:value=" item.DeliveryDetail.price == '0' ? '' : item.DeliveryDetail.price"
|
style="font-size: 14px;border: 0;width: 100%"/>
|
|
</td>
|
<td>
|
<input
|
v-if="props.type===1"
|
:value=" item.DeliveryDetail.money == '0' ? '' : item.DeliveryDetail.money "
|
style="font-size: 14px;border: 0;width: 100%"/>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
<table class="foot" >
|
<tr >
|
<td style="width: 5cm"></td>
|
<td style="width: 150px" ></td>
|
<td style="width: 65px" >
|
<input
|
:value=" getQuantitySum(pageIndex) "
|
style="font-size: 17px;border: 0;width: 100%"/>
|
</td>
|
<td style="width: 100px">
|
<input style="border: 0;width: 100px;font-size: 17px" :value="getAreaSum(pageIndex)">
|
|
</td>
|
<td style="width: 80px"></td>
|
<td v-if="props.type===1">
|
<input
|
:value="getMoneySum(pageIndex)"
|
style="font-size: 17px;border: 0;width: 100%"/>
|
</td>
|
<td></td>
|
</tr>
|
<tr style="height: 0.65cm"><td></td></tr>
|
<tr>
|
<td colspan="6">
|
<el-row id="footsum" :gutter="20" >
|
<el-col :span="19"></el-col>
|
<el-col :span="5" style="font-size: 17px" >
|
<input v-model="delivery.creator"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:17px"/>
|
</el-col>
|
</el-row>
|
</td>
|
</tr>
|
<tr><td style="height: 1.6cm"></td></tr>
|
<tr>
|
<td colspan="6">
|
<el-row id="footsum1" :gutter="20" >
|
<el-col :span="2" ></el-col>
|
<el-col :span="3" style="font-size: 17px">
|
<input v-model="delivery.contacts"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:17px"/>
|
</el-col>
|
<el-col :span="7" style="font-size: 17px">
|
<input v-model="delivery.contactNumber"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:17px"/>
|
</el-col>
|
<el-col :span="1" ></el-col>
|
<el-col :span="11" style="font-size: 17px">
|
<input v-model="delivery.deliveryAddress "
|
style="border: 0;width: 100%;
|
height: 100%;font-size:17px"/>
|
|
</el-col>
|
</el-row>
|
</td>
|
</tr>
|
</table>
|
|
</div>
|
</div>
|
|
|
</template>
|
|
|
|
|
<style scoped>
|
*{
|
color: rgba(0, 0, 0, 0.8); /* 更深的黑色 */
|
font-family: 'Microsoft YaHei', '微软雅黑', sans-serif;
|
outline: none;
|
}
|
#sheet{
|
width: 21cm;
|
}
|
table{
|
width: 18.3cm
|
|
}
|
.content1 {
|
page-break-after: always;
|
height: 26.5cm;
|
position: relative;
|
}
|
span{
|
width: 7cm;
|
text-align: center;
|
}
|
tbody *{
|
font-size: 14px;
|
}
|
#footsum1,#footsum{
|
font-weight: bold;font-size: 17px;
|
}
|
|
@media print {
|
@page {
|
margin: 12mm 10mm 20mm 10mm
|
}
|
|
.foot{
|
position: absolute;
|
bottom: 0.95cm;
|
}
|
|
}
|
|
.textarea{
|
--el-border-color: rgba(255,255,255,0.0);
|
--el-input-focus-border-color: rgba(255,255,255,0.0);
|
--el-input-focus-border-width: 0px;
|
--el-input-hover-border-color: rgba(255,255,255,0.0);
|
--el-input-hover-border-width: 0px;
|
width: 100%;
|
word-break:break-all;
|
}
|
:deep(.el-textarea__inner){
|
color: #333333;
|
font-family: 'Microsoft YaHei', '微软雅黑', sans-serif;
|
font-size: 14px;
|
}
|
:deep(.aaa){
|
width: 150px;
|
}
|
:deep(.bbb){
|
width: 5cm;
|
}
|
:deep(#table-sum td){
|
font-size: 17px;
|
}
|
</style>
|