<script setup>
|
import request from "@/utils/request"
|
import {computed, onMounted, onUpdated, 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:8
|
})
|
const form = ref({})
|
let produceList2 = ref([])
|
|
|
const deliveryId = ref()
|
|
const pageData = ref()
|
watch(()=>props.optionVal,()=>{
|
//给数据进行分页
|
pageData.value = groupArrayByFive(produceList2.value[0].data)
|
delivery.value = produceList2.value[0].delivery
|
})
|
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)
|
}
|
|
})*/
|
let result = [];
|
arr.forEach(item => {
|
item.DeliveryDetailList.forEach(items => {
|
result.push(items)
|
})
|
})
|
let index=0
|
let number=0
|
let numberResult = [];
|
let results = [];
|
let productName=result[0]['product_name']
|
for (let i = 0; i < result.length; i ++) {
|
if(productName!=result[i]['product_name']){
|
productName=result[i]['product_name']
|
index++
|
}
|
number++
|
numberResult.push(result[i])
|
|
|
let next=false
|
if (i + 1 != result.length) {
|
if(result[i+1]['product_name']!=productName){
|
next=true
|
}
|
}else{
|
next=true
|
}
|
if(props.optionVal === null){
|
props.optionVal = 8
|
}
|
if((index==3 && next) ||number==props.optionVal){
|
results.push(numberResult);
|
index=0
|
number=0
|
numberResult=[]
|
}else{
|
if (i + 1 == result.length) {
|
results.push(numberResult);
|
index=0
|
number=0
|
numberResult=[]
|
}
|
}
|
|
|
|
|
|
}
|
|
/*for (let i = 0; i < result.length; i += 8) {
|
results.push(result.slice(i, i + 8));
|
}*/
|
|
for (let i = 0; i < results.length; i++) {
|
let name = results[i][0]['product_name'] //上一次名称
|
let key = 0; //相同数
|
for (let j = 0; j < results[i].length; j++) {
|
let thisName = results[i][j]['product_name'];
|
if (thisName != name) {
|
results[i][key].rowspan = j - key;
|
name=results[i][j]['product_name']
|
key = j;
|
}
|
if (j + 1 == results[i].length) {
|
results[i][key].rowspan = j - key+1;
|
name=results[i][j]['product_name']
|
}
|
|
}
|
}
|
|
|
return results;
|
}
|
|
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 pageHeightList = ref([])
|
/*onUpdated(() => {
|
const tables = document.getElementsByClassName('content1')
|
for(let i=0;i<tables.length;i++){
|
console.log(tables[i].querySelector('tbody'))
|
let tableHeight = tables[i].querySelector('tbody').offsetHeight
|
console.log(i+":"+tableHeight)
|
console.log("---------")
|
if(pageHeightList.value[i] === undefined && i==0){
|
pageHeightList.value[i] = 900-tableHeight
|
}
|
|
}
|
// console.log(pageHeightList.value)
|
// console.log("++++++++++")
|
})*/
|
|
const printSheet = () => {
|
}
|
let companyName = ref('洛阳玻璃公司')
|
|
const getQuantitySum = (page) => {
|
if (pageData.value[page] === undefined) {
|
return 0
|
}
|
return pageData.value[page].reduce((accumulator, currentValue) => {
|
return add(accumulator, currentValue.quantity)
|
}, 0)
|
|
|
}
|
const getAreaSum = (page) => {
|
if (pageData.value[page] === undefined) {
|
return 0
|
}
|
return pageData.value[page].reduce((accumulator, currentValue) => {
|
return add(accumulator, currentValue.area)
|
}, 0)
|
}
|
const getMoneySum = (page) => {
|
if (pageData.value[page] === undefined) {
|
return 0
|
}
|
return pageData.value[page].reduce((accumulator, currentValue) => {
|
return add(accumulator, currentValue.money)
|
}, 0)
|
}
|
|
|
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="7">
|
<el-row :gutter="20">
|
<el-col :span="2"></el-col>
|
<el-col :span="10">
|
<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="1"></el-col>
|
<el-col :span="5" style="white-space: nowrap;font-size:19px;font-weight: bold">
|
<input v-model="deliveryDate"
|
style="border: 0;width: 150%;
|
height: 100%;font-size:19px;font-weight: bold;white-space: nowrap; margin-left: 80px"/>
|
</el-col>
|
</el-row>
|
</td>
|
</tr>
|
<tr style="height: 0.1cm">
|
<td></td>
|
</tr>
|
|
<tr style="margin-top: 20px">
|
<td colspan="7">
|
<el-row :gutter="20">
|
<el-col :span="2"></el-col>
|
<el-col :span="17" 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="5" style="font-size: 16px;white-space: nowrap;">
|
<input v-model="delivery.project"
|
style="border: 0;width: 250%;
|
height: 100%;font-size:16px;white-space: nowrap; "/>
|
</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: 16px;"> {{ delivery.orderId }}</el-col>
|
</el-row>
|
</td>
|
</tr>
|
|
<tr style="height: 1cm">
|
<td></td>
|
</tr>
|
|
|
</thead>
|
<tbody >
|
<template v-for="(items,index1) in page">
|
<tr>
|
<td style="width: 3.3cm" :rowspan="items.rowspan" v-if="items.rowspan!==undefined">
|
<el-input class="textarea" type="textarea"
|
:autosize="{ minRows: 1, maxRows: 20 }"
|
v-model="items.product_name"/>
|
</td>
|
<td style="width: 1.5cm">
|
<el-input class="textarea ccc" type="textarea"
|
:autosize="{ minRows: 1, maxRows: 20 }"
|
v-model="items.building_number"/>
|
</td>
|
|
<td style="width: 2cm">
|
<input style="font-size: 16px;border: 0;width: 100%"
|
v-model="items.width"/>
|
|
</td>
|
<td style="width: 2cm">
|
<input style="font-size: 16px;border: 0;width: 100%"
|
v-model="items.height"/>
|
|
</td>
|
<td style="width: 60px; font-size: 16px;">
|
{{ items.quantity }}
|
</td>
|
<td style="width: 100px">
|
<input style="font-size: 16px; border: 0;width: 100px" v-model="items.area">
|
</td>
|
|
<td
|
style="width: 80px"
|
>
|
<input
|
v-if="props.type===3"
|
:value=" items.price == '0' ? '' : items.price"
|
style="font-size: 14px;border: 0;width: 100%"/>
|
</td>
|
<td>
|
<input
|
v-if="props.type===3"
|
:value="items.money == '0' ? '' : items.money"
|
style="font-size: 14px;border: 0;width: 100%"/>
|
</td>
|
|
</tr>
|
</template>
|
</tbody>
|
</table>
|
<table class="foot">
|
<tr id="table-sum">
|
<td style="width: 3.3cm"></td>
|
<td style="width: 1.5cm"></td>
|
<td style="width: 2cm"></td>
|
<td style="width: 2cm"></td>
|
<td style="width: 60px">
|
<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 >
|
<input
|
v-if="props.type===3"
|
:value="getMoneySum(pageIndex) == '0.00' ? '' : getMoneySum(pageIndex)"
|
style="font-size: 17px;border: 0;width: 100%"/>
|
</td>
|
|
</tr>
|
<tr style="height: 0.65cm"><td></td></tr>
|
<tr>
|
<td colspan="8">
|
<el-row id="footsum" :gutter="40">
|
<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;white-space: nowrap;"/>
|
</el-col>
|
</el-row>
|
</td>
|
</tr>
|
<tr><td style="height: 1.6cm"></td></tr>
|
<tr>
|
<td colspan="8">
|
<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;white-space: nowrap;"/>
|
</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;white-space: nowrap;"/>
|
</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;white-space: nowrap;"/>
|
</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-size: 17px;
|
}
|
|
@media print {
|
@page {
|
margin: 12mm 10mm 20mm 10mm !important;
|
}
|
|
/*#footsum{
|
position: fixed;
|
bottom: 3.5cm;
|
width: 100%; !* 或者设置成具体的宽度 *!
|
font-size: 17px;
|
}
|
|
#footsum1 {
|
position: fixed;
|
bottom: 1cm;
|
width: 100%; !* 或者设置成具体的宽度 *!
|
}*/
|
.foot{
|
position: absolute;
|
bottom: 0.1cm;
|
//transform: translateY(8cm);
|
}
|
/*#table-sum {
|
position: absolute;
|
bottom: 5cm;
|
}
|
#sum_td{
|
width: 9cm;
|
}*/
|
|
}
|
|
.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;
|
word-break:break-all;
|
}
|
|
/*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: 14px;
|
}
|
:deep(#table-sum td){
|
font-size: 17px;
|
}
|
|
:deep(.ccc .el-textarea__inner) {
|
font-size: 11px;
|
}
|
</style>
|