业务联单取值有误,项目部材料站站长暂时要,项目部技术员是业务联系单创建人
This commit is contained in:
parent
3c7c64462e
commit
12a65812af
|
|
@ -167,7 +167,8 @@
|
||||||
<div>说明:</div>
|
<div>说明:</div>
|
||||||
<div>{{ '第一项目管理部(合肥肥东)' }}:</div>
|
<div>{{ '第一项目管理部(合肥肥东)' }}:</div>
|
||||||
<div>项目部材料站站长联系人:{{ '徐青松' }} {{ '15234213324' }}</div>
|
<div>项目部材料站站长联系人:{{ '徐青松' }} {{ '15234213324' }}</div>
|
||||||
<div>项目部技术联系人:{{ '杨金勇' }} {{ '17832421245' }}</div>
|
<!-- <div>项目部技术联系人:{{ '杨金勇' }} {{ '17832421245' }}</div> -->
|
||||||
|
<div>项目部技术联系人:{{ dialogForm.createBy }} {{ dialogForm.phone }}</div>
|
||||||
<div>领取人员:{{ dialogForm.leaseUnit }} {{ dialogForm.leasePerson }}:{{ dialogForm.phone }}</div>
|
<div>领取人员:{{ dialogForm.leaseUnit }} {{ dialogForm.leasePerson }}:{{ dialogForm.phone }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -263,9 +264,9 @@
|
||||||
<script>
|
<script>
|
||||||
import printJS from 'print-js'
|
import printJS from 'print-js'
|
||||||
import { getLeaseTaskList, deleteLeaseTask, getLeaseTask, getCodePDF } from '@/api/business/index'
|
import { getLeaseTaskList, deleteLeaseTask, getLeaseTask, getCodePDF } from '@/api/business/index'
|
||||||
import html2canvas from 'html2canvas';
|
import html2canvas from 'html2canvas'
|
||||||
import jsPDF from 'jspdf';
|
import jsPDF from 'jspdf'
|
||||||
import request from "@/utils/request";
|
import request from '@/utils/request'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Index',
|
name: 'Index',
|
||||||
|
|
@ -286,7 +287,7 @@ export default {
|
||||||
{ label: '待审核', value: '0' },
|
{ label: '待审核', value: '0' },
|
||||||
{ label: '审核中', value: '6' },
|
{ label: '审核中', value: '6' },
|
||||||
{ label: '已完成', value: '2' },
|
{ label: '已完成', value: '2' },
|
||||||
{ label: '已驳回', value: '3' },
|
{ label: '已驳回', value: '3' }
|
||||||
],
|
],
|
||||||
total: 0, // 总条数
|
total: 0, // 总条数
|
||||||
// 表头
|
// 表头
|
||||||
|
|
@ -403,34 +404,34 @@ export default {
|
||||||
}
|
}
|
||||||
},*/
|
},*/
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const formatTime = (date) => {
|
const formatTime = date => {
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear()
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
const hours = String(date.getHours()).padStart(2, '0')
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||||
return `${year}${month}${day}_${hours}${minutes}${seconds}`;
|
return `${year}${month}${day}_${hours}${minutes}${seconds}`
|
||||||
};
|
}
|
||||||
|
|
||||||
const currentTime = formatTime(new Date());
|
const currentTime = formatTime(new Date())
|
||||||
this.download(
|
this.download(
|
||||||
"/material/leaseTask/exportLeaseRecord",
|
'/material/leaseTask/exportLeaseRecord',
|
||||||
{ ...this.queryParams },
|
{ ...this.queryParams },
|
||||||
`领用记录数据_${currentTime}.xlsx`
|
`领用记录数据_${currentTime}.xlsx`
|
||||||
);
|
)
|
||||||
},
|
},
|
||||||
// 打印
|
// 打印
|
||||||
print() {
|
print() {
|
||||||
const element = document.getElementById('print-content');
|
const element = document.getElementById('print-content')
|
||||||
|
|
||||||
// 确保元素存在
|
// 确保元素存在
|
||||||
if (!element) {
|
if (!element) {
|
||||||
this.$message.error('未找到要打印的元素');
|
this.$message.error('未找到要打印的元素')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$modal.loading('正在生成单据,请稍候...');
|
this.$modal.loading('正在生成单据,请稍候...')
|
||||||
|
|
||||||
// 使用html2canvas将DOM元素转换为canvas
|
// 使用html2canvas将DOM元素转换为canvas
|
||||||
html2canvas(element, {
|
html2canvas(element, {
|
||||||
|
|
@ -438,43 +439,46 @@ export default {
|
||||||
useCORS: true, // 允许加载跨域图片
|
useCORS: true, // 允许加载跨域图片
|
||||||
allowTaint: true,
|
allowTaint: true,
|
||||||
backgroundColor: '#ffffff'
|
backgroundColor: '#ffffff'
|
||||||
}).then(canvas => {
|
})
|
||||||
|
.then(canvas => {
|
||||||
// 创建PDF文档
|
// 创建PDF文档
|
||||||
const pdf = new jsPDF('p', 'mm', 'a4');
|
const pdf = new jsPDF('p', 'mm', 'a4')
|
||||||
|
|
||||||
// 获取canvas的宽度和高度
|
// 获取canvas的宽度和高度
|
||||||
const imgWidth = 210; // A4纸的宽度(mm)
|
const imgWidth = 210 // A4纸的宽度(mm)
|
||||||
const pageHeight = 297; // A4纸的高度(mm)
|
const pageHeight = 297 // A4纸的高度(mm)
|
||||||
const imgHeight = canvas.height * imgWidth / canvas.width;
|
const imgHeight = (canvas.height * imgWidth) / canvas.width
|
||||||
|
|
||||||
// 将canvas转换为图片
|
// 将canvas转换为图片
|
||||||
const imgData = canvas.toDataURL('image/jpeg', 1.0);
|
const imgData = canvas.toDataURL('image/jpeg', 1.0)
|
||||||
|
|
||||||
// 添加图片到PDF
|
// 添加图片到PDF
|
||||||
pdf.addImage(imgData, 'JPEG', 0, 0, imgWidth, imgHeight);
|
pdf.addImage(imgData, 'JPEG', 0, 0, imgWidth, imgHeight)
|
||||||
|
|
||||||
// 生成PDF文件名
|
// 生成PDF文件名
|
||||||
const fileName = `业务联系单_${this.dialogForm.code || '未命名'}_${new Date().getTime()}.pdf`;
|
const fileName = `业务联系单_${this.dialogForm.code || '未命名'}_${new Date().getTime()}.pdf`
|
||||||
|
|
||||||
// 将PDF转换为Blob对象
|
// 将PDF转换为Blob对象
|
||||||
const pdfBlob = pdf.output('blob');
|
const pdfBlob = pdf.output('blob')
|
||||||
|
|
||||||
// 创建FormData对象用于上传
|
// 创建FormData对象用于上传
|
||||||
const formData = new FormData();
|
const formData = new FormData()
|
||||||
formData.append('file', pdfBlob, fileName);
|
formData.append('file', pdfBlob, fileName)
|
||||||
formData.append('id', this.dialogForm.leaseProjectId);
|
formData.append('id', this.dialogForm.leaseProjectId)
|
||||||
|
|
||||||
// 上传到服务器
|
// 上传到服务器
|
||||||
this.$modal.closeLoading();
|
this.$modal.closeLoading()
|
||||||
|
|
||||||
// 调用上传API - 使用request
|
// 调用上传API - 使用request
|
||||||
request.post('/material/leaseTask/uploadPdf', formData, {
|
request
|
||||||
|
.post('/material/leaseTask/uploadPdf', formData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data'
|
||||||
}
|
}
|
||||||
}).then(response => {
|
})
|
||||||
|
.then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$modal.msgSuccess('单据文件已保存到服务器');
|
this.$modal.msgSuccess('单据文件已保存到服务器')
|
||||||
|
|
||||||
// 上传成功后执行打印
|
// 上传成功后执行打印
|
||||||
printJS({
|
printJS({
|
||||||
|
|
@ -482,12 +486,13 @@ export default {
|
||||||
type: 'html',
|
type: 'html',
|
||||||
scanStyles: false,
|
scanStyles: false,
|
||||||
maxWidth: '1400'
|
maxWidth: '1400'
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$modal.msgError('保存单据文件失败');
|
this.$modal.msgError('保存单据文件失败')
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
})
|
||||||
this.$modal.msgError('上传单据文件时发生错误');
|
.catch(() => {
|
||||||
|
this.$modal.msgError('上传单据文件时发生错误')
|
||||||
|
|
||||||
// 即使上传失败也执行打印
|
// 即使上传失败也执行打印
|
||||||
printJS({
|
printJS({
|
||||||
|
|
@ -495,13 +500,14 @@ export default {
|
||||||
type: 'html',
|
type: 'html',
|
||||||
scanStyles: false,
|
scanStyles: false,
|
||||||
maxWidth: '1400'
|
maxWidth: '1400'
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}).catch(error => {
|
})
|
||||||
this.$modal.closeLoading();
|
.catch(error => {
|
||||||
this.$modal.msgError('生成单据时发生错误');
|
this.$modal.closeLoading()
|
||||||
console.error('生成单据错误:', error);
|
this.$modal.msgError('生成单据时发生错误')
|
||||||
});
|
console.error('生成单据错误:', error)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
// 获取弹框内容
|
// 获取弹框内容
|
||||||
async getDialogContent(row) {
|
async getDialogContent(row) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue