diff --git a/klp-ui/.gitignore b/klp-ui/.gitignore index 78a752d8..957d8b62 100644 --- a/klp-ui/.gitignore +++ b/klp-ui/.gitignore @@ -12,6 +12,7 @@ selenium-debug.log # Editor directories and files .idea +.trae .vscode *.suo *.ntvs* diff --git a/klp-ui/src/api/menu.js b/klp-ui/src/api/menu.js index faef101c..27e8a5aa 100644 --- a/klp-ui/src/api/menu.js +++ b/klp-ui/src/api/menu.js @@ -1,9 +1,29 @@ import request from '@/utils/request' -// 获取路由 +const addParentPrefix = (menuList, parentName = '') => { + return menuList.map(menu => { + const newName = parentName ? `${parentName}-${menu.name}` : menu.name + const newMenu = { ...menu, name: newName } + if (menu.children && menu.children.length > 0) { + newMenu.children = addParentPrefix(menu.children, newName) + } + return newMenu + }) +} + export const getRouters = () => { return request({ url: '/getRouters', method: 'get' - }) + }).then(res => { + if (res && Array.isArray(res.data)) { + return { + data: addParentPrefix(res.data), + code: 200, + msg: 'success' + } + } + console.log(res, 'getRouters res') + return res + }) } \ No newline at end of file diff --git a/klp-ui/src/api/mes/qc/certificate.js b/klp-ui/src/api/mes/qc/certificate.js new file mode 100644 index 00000000..4a93f7f9 --- /dev/null +++ b/klp-ui/src/api/mes/qc/certificate.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询质量证明书主列表 +export function listCertificate(query) { + return request({ + url: '/qc/certificate/list', + method: 'get', + params: query + }) +} + +// 查询质量证明书主详细 +export function getCertificate(certificateId) { + return request({ + url: '/qc/certificate/' + certificateId, + method: 'get' + }) +} + +// 新增质量证明书主 +export function addCertificate(data) { + return request({ + url: '/qc/certificate', + method: 'post', + data: data + }) +} + +// 修改质量证明书主 +export function updateCertificate(data) { + return request({ + url: '/qc/certificate', + method: 'put', + data: data + }) +} + +// 删除质量证明书主 +export function delCertificate(certificateId) { + return request({ + url: '/qc/certificate/' + certificateId, + method: 'delete' + }) +} diff --git a/klp-ui/src/api/mes/qc/certificateItem.js b/klp-ui/src/api/mes/qc/certificateItem.js new file mode 100644 index 00000000..ef070f90 --- /dev/null +++ b/klp-ui/src/api/mes/qc/certificateItem.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询质量证明书明细列表 +export function listCertificateItem(query) { + return request({ + url: '/qc/certificateItem/list', + method: 'get', + params: query + }) +} + +// 查询质量证明书明细详细 +export function getCertificateItem(itemId) { + return request({ + url: '/qc/certificateItem/' + itemId, + method: 'get' + }) +} + +// 新增质量证明书明细 +export function addCertificateItem(data) { + return request({ + url: '/qc/certificateItem', + method: 'post', + data: data + }) +} + +// 修改质量证明书明细 +export function updateCertificateItem(data) { + return request({ + url: '/qc/certificateItem', + method: 'put', + data: data + }) +} + +// 删除质量证明书明细 +export function delCertificateItem(itemId) { + return request({ + url: '/qc/certificateItem/' + itemId, + method: 'delete' + }) +} diff --git a/klp-ui/src/assets/images/yanghongyan.png b/klp-ui/src/assets/images/yanghongyan.png new file mode 100644 index 00000000..17f23c76 Binary files /dev/null and b/klp-ui/src/assets/images/yanghongyan.png differ diff --git a/klp-ui/src/assets/images/zhijian.png b/klp-ui/src/assets/images/zhijian.png new file mode 100644 index 00000000..d6faf0b3 Binary files /dev/null and b/klp-ui/src/assets/images/zhijian.png differ diff --git a/klp-ui/src/components/KLPService/index.js b/klp-ui/src/components/KLPService/index.js index 4b1d9f92..13f81c54 100644 --- a/klp-ui/src/components/KLPService/index.js +++ b/klp-ui/src/components/KLPService/index.js @@ -1,4 +1,5 @@ export { default as CheckItemSelect } from './CheckItemSelect/index.vue'; +export { default as SchemeSelect } from './SchemeSelect/index.vue'; export { default as ProductSelect } from './ProductSelect/index.vue'; export { default as RawMaterialSelect } from './RawMaterialSelect/index.vue'; export { default as UserSelect } from './UserSelect/index.vue'; diff --git a/klp-ui/src/views/mes/qc/certificate/book.vue b/klp-ui/src/views/mes/qc/certificate/book.vue new file mode 100644 index 00000000..636aa692 --- /dev/null +++ b/klp-ui/src/views/mes/qc/certificate/book.vue @@ -0,0 +1,657 @@ + + + + + diff --git a/klp-ui/src/views/mes/qc/certificate/components/CertificatePrintPreview.vue b/klp-ui/src/views/mes/qc/certificate/components/CertificatePrintPreview.vue new file mode 100644 index 00000000..8cc320f7 --- /dev/null +++ b/klp-ui/src/views/mes/qc/certificate/components/CertificatePrintPreview.vue @@ -0,0 +1,384 @@ + + + + + diff --git a/klp-ui/src/views/mes/qc/certificate/item.vue b/klp-ui/src/views/mes/qc/certificate/item.vue new file mode 100644 index 00000000..d11d173c --- /dev/null +++ b/klp-ui/src/views/mes/qc/certificate/item.vue @@ -0,0 +1,888 @@ + + + + + diff --git a/klp-ui/src/views/mes/qc/certificate/lib/printUtils.js b/klp-ui/src/views/mes/qc/certificate/lib/printUtils.js new file mode 100644 index 00000000..1d9b73bf --- /dev/null +++ b/klp-ui/src/views/mes/qc/certificate/lib/printUtils.js @@ -0,0 +1,95 @@ +import html2canvas from 'html2canvas'; +import { PDFDocument } from 'pdf-lib'; + +async function generatePdf(domElement) { + const originalParent = domElement.parentNode; + const originalNext = domElement.nextSibling; + + const paperWidthMm = 297; + const paperHeightMm = 210; + + const wrapper = document.createElement('div'); + wrapper.style.cssText = `position:fixed;left:-100000px;top:0;width:${paperWidthMm}mm;height:${paperHeightMm}mm;box-sizing:border-box;background-color:#ffffff;overflow:hidden;`; + wrapper.appendChild(domElement); + document.body.appendChild(wrapper); + + await document.fonts.ready; + await new Promise(resolve => setTimeout(resolve, 300)); + + try { + const containerWidth = domElement.offsetWidth || domElement.scrollWidth; + const containerHeight = domElement.offsetHeight || domElement.scrollHeight; + + const canvas = await html2canvas(domElement, { + scale: 2, + useCORS: true, + backgroundColor: '#ffffff', + logging: false, + width: containerWidth, + height: containerHeight, + windowWidth: containerWidth, + windowHeight: containerHeight + }); + + const pdfDoc = await PDFDocument.create(); + const mmToPt = 72 / 25.4; + const pageWidthPt = paperWidthMm * mmToPt; + const pageHeightPt = paperHeightMm * mmToPt; + const page = pdfDoc.addPage([pageWidthPt, pageHeightPt]); + + const pngImage = await pdfDoc.embedPng(canvas.toDataURL('image/png')); + const imgWidth = page.getWidth(); + const imgHeight = (pngImage.height * imgWidth) / pngImage.width; + + if (imgHeight > page.getHeight()) { + const scale = page.getHeight() / imgHeight; + page.drawImage(pngImage, { + x: (page.getWidth() - imgWidth * scale) / 2, + y: 0, + width: imgWidth * scale, + height: page.getHeight() + }); + } else { + page.drawImage(pngImage, { + x: 0, + y: (page.getHeight() - imgHeight) / 2, + width: imgWidth, + height: imgHeight + }); + } + + const pdfBytes = await pdfDoc.save(); + return pdfBytes; + } finally { + if (originalParent) { + if (originalNext) { + originalParent.insertBefore(domElement, originalNext); + } else { + originalParent.appendChild(domElement); + } + } + if (wrapper.parentNode) { + document.body.removeChild(wrapper); + } + } +} + +export async function downloadPdf(domElement, fileName) { + const pdfBytes = await generatePdf(domElement); + const blob = new Blob([pdfBytes], { type: 'application/pdf' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = fileName || `certificate_${new Date().getTime()}.pdf`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); +} + +export async function print(domElement) { + const pdfBytes = await generatePdf(domElement); + const blob = new Blob([pdfBytes], { type: 'application/pdf' }); + const url = URL.createObjectURL(blob); + const printWindow = window.open(url, '_blank'); +}