<script setup>
|
import request from "@/utils/request"
|
import {computed, onMounted, ref} 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
|
})
|
const form = ref({
|
})
|
let produceList2 = ref([])
|
|
|
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){
|
console.log(res.data)
|
produceList.value = deepClone(res.data)
|
for(let i=0;i<produceList.value.length;i++){
|
produceList.value[i].data.forEach(item =>{
|
|
|
})
|
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)
|
console.log(pageData.value)
|
delivery.value = produceList2.value[0].delivery
|
console.log(delivery.value)
|
|
|
|
}else{
|
ElMessage.warning(res.msg)
|
router.push("/login")
|
}
|
})
|
}
|
|
function groupArrayByFive(arr) {
|
|
let result = [];
|
let productName=ref()
|
arr.forEach(item=>{
|
for (let i = 0; i < item.DeliveryDetailList.length; i += 8) {
|
let resultMap = {
|
id:null,
|
DeliveryDetail:null,
|
DeliveryDetailList:[]
|
};
|
resultMap.DeliveryDetail=item.DeliveryDetail
|
resultMap.id=item.DeliveryDetailList.slice(i, i + 8).length
|
resultMap.DeliveryDetailList.push(item.DeliveryDetailList.slice(i, i + 8))
|
result.push(resultMap)
|
}
|
|
})
|
|
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 printSheet = () => {
|
}
|
let companyName = ref('洛阳玻璃公司')
|
|
const getQuantitySum = (page)=>{
|
if(pageData.value[page] === undefined){
|
return 0
|
}
|
return pageData.value[page].DeliveryDetailList[0].reduce((accumulator, currentValue) => {
|
return add(accumulator,currentValue.quantity)
|
}, 0)
|
|
|
}
|
const getAreaSum = (page)=>{
|
if(pageData.value[page] === undefined){
|
return 0
|
}
|
return pageData.value[page].DeliveryDetailList[0].reduce((accumulator, currentValue) => {
|
return addAuto(accumulator,currentValue.area,2)
|
}, 0)
|
}
|
const getMoneySum = (page)=>{
|
if(pageData.value[page] === undefined){
|
return 0
|
}
|
return pageData.value[page].DeliveryDetailList[0].reduce((accumulator, currentValue) => {
|
return addAuto(accumulator,currentValue.money,2)
|
}, 0)
|
}
|
|
|
defineExpose({
|
printSheet
|
});
|
</script>
|
|
<template>
|
<div >
|
<el-row id="footsum" :gutter="20" >
|
<el-col :span="20"></el-col>
|
<el-col :span="4" style="font-size: 17px" >{{delivery.creator}}</el-col>
|
</el-row>
|
<el-row id="footsum1" :gutter="20" >
|
<el-col :span="2" ></el-col>
|
<el-col :span="3" style="font-size: 17px">{{ delivery.contacts }}</el-col>
|
<el-col :span="7" style="font-size: 17px">{{ delivery.contactNumber }}</el-col>
|
<el-col :span="1" ></el-col>
|
<el-col :span="11" style="font-size: 17px">{{ delivery.deliveryAddress }}</el-col>
|
</el-row>
|
|
<table class="content1" v-for="(page,pageIndex) in pageData" >
|
<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="9">
|
<input v-model="companyName"
|
style="border: 0;width: 100%;
|
height: 100%;font-size:19px;font-weight: bold "/>
|
</el-col>
|
<el-col :span="5" style="font-size:19px;font-weight: bold"> {{deliveryId}} </el-col>
|
<el-col :span="6"></el-col>
|
<el-col :span="2" style="white-space: nowrap;font-size:19px;font-weight: bold">{{deliveryDate}}</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="17" style="font-size: 16px;">{{delivery.customerName }}</el-col>
|
|
<el-col :span="5" style="font-size: 16px;white-space: nowrap;"> {{delivery.project }}</el-col>
|
</el-row>
|
</td>
|
</tr>
|
<tr style="height: 0.1cm"><td></td></tr>
|
<tr>
|
<td colspan="6">
|
<el-row :gutter="20">
|
<el-col :span="2"></el-col>
|
<el-col :span="12" style="font-size: 17px;font-weight: bold"> {{delivery.orderId }}</el-col>
|
</el-row>
|
</td>
|
</tr>
|
|
<tr style="height: 1cm"><td></td></tr>
|
|
|
|
</thead>
|
<tbody >
|
<template v-for="(items,index1) in page.DeliveryDetailList[0]">
|
<tr>
|
|
<td style="width: 4cm" :rowspan="page.id" v-if="index1===0">
|
<el-input class="textarea" type="textarea"
|
:autosize="{ minRows: 1, maxRows: 20 }"
|
v-model="page.DeliveryDetail.orderDetail.productName" />
|
</td>
|
<td style="width: 0.8cm"></td>
|
|
<td style="width: 2cm">
|
<el-input class="textarea" type="textarea"
|
:autosize="{ minRows: 1, maxRows: 20 }"
|
v-model="items.width" />
|
|
</td>
|
<td style="width: 2cm">
|
<el-input class="textarea" type="textarea"
|
:autosize="{ minRows: 1, maxRows: 20 }"
|
v-model="items.height" />
|
|
</td>
|
<td style="width: 60px">
|
{{items.quantity}}
|
</td>
|
<td style="width: 100px">
|
<input style="border: 0;width: 100px" v-model="items.area">
|
</td>
|
|
<td
|
v-if="props.type===1||props.type===3"
|
style="width: 80px"
|
>
|
{{items.price}}
|
</td>
|
<td
|
v-if="props.type===1||props.type===3"
|
>
|
{{items.money}}
|
</td>
|
|
</tr>
|
</template>
|
<tr>
|
<td></td>
|
<td></td>
|
<td></td>
|
<td></td>
|
<td>
|
{{getQuantitySum(pageIndex)}}
|
</td>
|
<td>
|
<input style="border: 0;width: 100px" :value="getAreaSum(pageIndex)">
|
</td>
|
<td></td>
|
<td v-if="props.type===1||props.type===3">
|
{{getMoneySum(pageIndex)}}
|
</td>
|
|
</tr>
|
|
</tbody>
|
</table>
|
|
|
</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;
|
|
}
|
span{
|
width: 7cm;
|
text-align: center;
|
}
|
tbody *{
|
font-size: 12px;
|
}
|
#footsum1,#footsum{
|
font-size: 17px;
|
}
|
|
@media print {
|
#footsum{
|
position: fixed;
|
bottom: 3.5cm;
|
width: 100%; /* 或者设置成具体的宽度 */
|
font-size: 17px;
|
}
|
#footsum1{
|
position: fixed;
|
bottom: 1cm;
|
width: 100%; /* 或者设置成具体的宽度 */
|
}
|
}
|
|
.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;
|
}
|
/*textarea {
|
|
font-size: 16px;
|
border:none;
|
text-align: right;
|
font-weight: bold;
|
width: 100%;
|
height: 100%;
|
}*/
|
:deep(.el-textarea__inner){
|
color: #333333;
|
font-family: 'Microsoft YaHei', '微软雅黑', sans-serif;
|
font-size: 12px;
|
}
|
|
|
</style>
|