|
|
@ -60,13 +60,6 @@ |
|
|
|
inner-text="查看" |
|
|
|
inner-text="查看" |
|
|
|
@click="onView(scope.row)" |
|
|
|
@click="onView(scope.row)" |
|
|
|
/><el-divider direction="vertical" /> |
|
|
|
/><el-divider direction="vertical" /> |
|
|
|
<EdfsButton |
|
|
|
|
|
|
|
link |
|
|
|
|
|
|
|
type="primary" |
|
|
|
|
|
|
|
inner-text="打印标签" |
|
|
|
|
|
|
|
@click="onPrint(scope.row)" |
|
|
|
|
|
|
|
/><el-divider direction="vertical" /> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-dropdown @command="command => handleCommand(command, scope.row)"> |
|
|
|
<el-dropdown @command="command => handleCommand(command, scope.row)"> |
|
|
|
<el-button type="primary" link |
|
|
|
<el-button type="primary" link |
|
|
|
><Icon icon="ep:d-arrow-right" /> 更多</el-button |
|
|
|
><Icon icon="ep:d-arrow-right" /> 更多</el-button |
|
|
@ -82,6 +75,23 @@ |
|
|
|
<el-dropdown-item command="delivery" v-if="scope.row.status === 2"> |
|
|
|
<el-dropdown-item command="delivery" v-if="scope.row.status === 2"> |
|
|
|
<Icon icon="solar:inbox-out-outline" />出库 |
|
|
|
<Icon icon="solar:inbox-out-outline" />出库 |
|
|
|
</el-dropdown-item> |
|
|
|
</el-dropdown-item> |
|
|
|
|
|
|
|
<el-dropdown-menu> |
|
|
|
|
|
|
|
<Icon |
|
|
|
|
|
|
|
icon="solar:printer-outline" |
|
|
|
|
|
|
|
command="printLabel " |
|
|
|
|
|
|
|
v-if="scope.row.status >= 1" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
打印标签 |
|
|
|
|
|
|
|
</el-dropdown-menu> |
|
|
|
|
|
|
|
<el-dropdown-menu> |
|
|
|
|
|
|
|
<Icon |
|
|
|
|
|
|
|
icon="solar:printer-outline" |
|
|
|
|
|
|
|
command="printReport" |
|
|
|
|
|
|
|
v-if="scope.row.status >= 2" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
打印测试报告 |
|
|
|
|
|
|
|
</el-dropdown-menu> |
|
|
|
|
|
|
|
|
|
|
|
<el-dropdown-item command="maintain" v-if="scope.row.status >= 3"> |
|
|
|
<el-dropdown-item command="maintain" v-if="scope.row.status >= 3"> |
|
|
|
<Icon icon="solar:minimalistic-magnifer-bug-outline" />设备报修 |
|
|
|
<Icon icon="solar:minimalistic-magnifer-bug-outline" />设备报修 |
|
|
|
</el-dropdown-item> |
|
|
|
</el-dropdown-item> |
|
|
@ -109,8 +119,10 @@ import { |
|
|
|
getDeviceLabelBase64, |
|
|
|
getDeviceLabelBase64, |
|
|
|
getDevicePage, |
|
|
|
getDevicePage, |
|
|
|
getDeviceSummaryByStatus, |
|
|
|
getDeviceSummaryByStatus, |
|
|
|
|
|
|
|
getDeviceReportPDF, |
|
|
|
type IDevice, |
|
|
|
type IDevice, |
|
|
|
} from '@/api/module/eam/device' |
|
|
|
} from '@/api/module/eam/device' |
|
|
|
|
|
|
|
import { ElLoading } from 'element-plus' |
|
|
|
import { deviceTableCol, DeviceStatus } from './utils' |
|
|
|
import { deviceTableCol, DeviceStatus } from './utils' |
|
|
|
import { getCategoryTree, type ICategoryTree } from '@/api/module/eam/device/category' |
|
|
|
import { getCategoryTree, type ICategoryTree } from '@/api/module/eam/device/category' |
|
|
|
import jsPDF from 'jspdf' |
|
|
|
import jsPDF from 'jspdf' |
|
|
@ -196,7 +208,9 @@ function onView(row: any) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function onPrint(row: any) { |
|
|
|
async function onPrint(row: any) { |
|
|
|
|
|
|
|
setLoadingPrint() |
|
|
|
const res = await getDeviceLabelBase64(row.id) |
|
|
|
const res = await getDeviceLabelBase64(row.id) |
|
|
|
|
|
|
|
closeLoadingPrint() |
|
|
|
if (isResError(res)) return |
|
|
|
if (isResError(res)) return |
|
|
|
const pdf = new jsPDF('l', 'mm', [60, 40]) |
|
|
|
const pdf = new jsPDF('l', 'mm', [60, 40]) |
|
|
|
|
|
|
|
|
|
|
@ -204,15 +218,47 @@ async function onPrint(row: any) { |
|
|
|
const imgWidth = 60 |
|
|
|
const imgWidth = 60 |
|
|
|
const imgHeight = 40 |
|
|
|
const imgHeight = 40 |
|
|
|
|
|
|
|
|
|
|
|
// 添加图片到标签的 PDF 中 |
|
|
|
|
|
|
|
pdf.addImage(imgData, 'JPEG', 0, 0, imgWidth, imgHeight) |
|
|
|
pdf.addImage(imgData, 'JPEG', 0, 0, imgWidth, imgHeight) |
|
|
|
|
|
|
|
|
|
|
|
// 打开 PDF 打印对话框 |
|
|
|
|
|
|
|
pdf.autoPrint() |
|
|
|
pdf.autoPrint() |
|
|
|
window.open(pdf.output('bloburl'), '_blank') |
|
|
|
window.open(pdf.output('bloburl'), '_blank') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const loadingPrint = ref<any>() |
|
|
|
|
|
|
|
function setLoadingPrint() { |
|
|
|
|
|
|
|
loadingPrint.value = ElLoading.service({ |
|
|
|
|
|
|
|
lock: true, |
|
|
|
|
|
|
|
text: '打印中请稍等...', |
|
|
|
|
|
|
|
spinner: 'el-icon-loading', |
|
|
|
|
|
|
|
background: 'rgba(0, 0, 0, 0.7)', |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function closeLoadingPrint() { |
|
|
|
|
|
|
|
loadingPrint.value.close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function onPrintReport(row: any) { |
|
|
|
|
|
|
|
setLoadingPrint() |
|
|
|
|
|
|
|
const res = await getDeviceReportPDF(row.id) |
|
|
|
|
|
|
|
closeLoadingPrint() |
|
|
|
|
|
|
|
if (isResError(res)) return |
|
|
|
|
|
|
|
const pdfURL = URL.createObjectURL(res.data) |
|
|
|
|
|
|
|
const printWindow = window.open(pdfURL) as any |
|
|
|
|
|
|
|
printWindow.onload = () => { |
|
|
|
|
|
|
|
printWindow.print() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handleCommand(command: string, row: any) { |
|
|
|
function handleCommand(command: string, row: any) { |
|
|
|
|
|
|
|
if (command === 'printReport') { |
|
|
|
|
|
|
|
onPrintReport(row) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} else if (command === 'printLabel') { |
|
|
|
|
|
|
|
onPrint(row) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
editDevice(row, command) |
|
|
|
editDevice(row, command) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|