This commit is contained in:
zc
2026-04-16 00:47:58 +08:00
parent 3c03907e69
commit 4d52bceea5
10 changed files with 1243 additions and 398 deletions

View File

@@ -14,12 +14,16 @@ export interface MaterialInfoResp {
createUserString: string
updateUserString: string
lightLevel: number
batch: string
mark: string
disabled: boolean
photoLoadError: boolean
}
export interface MaterialInfoQuery {
materialName: string | undefined
encoding: string | undefined
batch: string | undefined
mark: string | undefined
sort: Array<string>
}

View File

@@ -10,6 +10,7 @@ export interface WeighManageResp {
unitWeight: number
photoUrl: string
batch: string
mark: string
materialProcess: string
matchResult: string
downFloatRatio: string

View File

@@ -11,6 +11,7 @@ export interface WorkOrderResp {
unitWeight: string
materialSpec: string
photoUrl: string
batch: string
totalWeight: string
totalCalculatedWeight: string
totalCount: string
@@ -19,6 +20,7 @@ export interface WorkOrderResp {
matchResult: string
workOrderInfos: Array<WorkOrderInfoResp>
qrCodeData: string
mark: string
}
export interface WorkOrderInfoResp {
@@ -26,15 +28,19 @@ export interface WorkOrderInfoResp {
workOrderId: string
materialId: string
weightTime: string
batch: string
quantity: string
weight: string
imgUrl: string
calculatedWeight: string
weightQuantity: string
mark: string
}
export interface WorkOrderQuery {
orderNo: string | undefined
materialName: string | undefined
batch: string | undefined
encoding: string | undefined
userName: string | undefined
carNo: string | undefined

View File

@@ -0,0 +1,145 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}
declare module 'vue' {
export interface GlobalComponents {
AAlert: typeof import('@arco-design/web-vue')['Alert']
AAvatar: typeof import('@arco-design/web-vue')['Avatar']
ABadge: typeof import('@arco-design/web-vue')['Badge']
ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb']
ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem']
AButton: typeof import('@arco-design/web-vue')['Button']
AButtonGroup: typeof import('@arco-design/web-vue')['ButtonGroup']
ACard: typeof import('@arco-design/web-vue')['Card']
ACardMeta: typeof import('@arco-design/web-vue')['CardMeta']
ACarousel: typeof import('@arco-design/web-vue')['Carousel']
ACarouselItem: typeof import('@arco-design/web-vue')['CarouselItem']
ACheckbox: typeof import('@arco-design/web-vue')['Checkbox']
ACheckboxGroup: typeof import('@arco-design/web-vue')['CheckboxGroup']
ACol: typeof import('@arco-design/web-vue')['Col']
AColorPicker: typeof import('@arco-design/web-vue')['ColorPicker']
AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider']
ADatePicker: typeof import('@arco-design/web-vue')['DatePicker']
ADescriptions: typeof import('@arco-design/web-vue')['Descriptions']
ADescriptionsItem: typeof import('@arco-design/web-vue')['DescriptionsItem']
ADivider: typeof import('@arco-design/web-vue')['Divider']
ADoption: typeof import('@arco-design/web-vue')['Doption']
ADrawer: typeof import('@arco-design/web-vue')['Drawer']
ADropdown: typeof import('@arco-design/web-vue')['Dropdown']
AEmpty: typeof import('@arco-design/web-vue')['Empty']
AForm: typeof import('@arco-design/web-vue')['Form']
AFormItem: typeof import('@arco-design/web-vue')['FormItem']
AGrid: typeof import('@arco-design/web-vue')['Grid']
AGridItem: typeof import('@arco-design/web-vue')['GridItem']
AImage: typeof import('@arco-design/web-vue')['Image']
AInput: typeof import('@arco-design/web-vue')['Input']
AInputGroup: typeof import('@arco-design/web-vue')['InputGroup']
AInputNumber: typeof import('@arco-design/web-vue')['InputNumber']
AInputPassword: typeof import('@arco-design/web-vue')['InputPassword']
AInputSearch: typeof import('@arco-design/web-vue')['InputSearch']
ALayout: typeof import('@arco-design/web-vue')['Layout']
ALayoutContent: typeof import('@arco-design/web-vue')['LayoutContent']
ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader']
ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider']
ALink: typeof import('@arco-design/web-vue')['Link']
AMenu: typeof import('@arco-design/web-vue')['Menu']
AMenuItem: typeof import('@arco-design/web-vue')['MenuItem']
AModal: typeof import('@arco-design/web-vue')['Modal']
AOption: typeof import('@arco-design/web-vue')['Option']
AOverflowList: typeof import('@arco-design/web-vue')['OverflowList']
APagination: typeof import('@arco-design/web-vue')['Pagination']
APopconfirm: typeof import('@arco-design/web-vue')['Popconfirm']
APopover: typeof import('@arco-design/web-vue')['Popover']
AProgress: typeof import('@arco-design/web-vue')['Progress']
ARadio: typeof import('@arco-design/web-vue')['Radio']
ARadioGroup: typeof import('@arco-design/web-vue')['RadioGroup']
ARangePicker: typeof import('@arco-design/web-vue')['RangePicker']
ARow: typeof import('@arco-design/web-vue')['Row']
AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar']
ASelect: typeof import('@arco-design/web-vue')['Select']
ASkeleton: typeof import('@arco-design/web-vue')['Skeleton']
ASkeletonLine: typeof import('@arco-design/web-vue')['SkeletonLine']
ASpace: typeof import('@arco-design/web-vue')['Space']
ASpin: typeof import('@arco-design/web-vue')['Spin']
AStatistic: typeof import('@arco-design/web-vue')['Statistic']
ASubMenu: typeof import('@arco-design/web-vue')['SubMenu']
ASwitch: typeof import('@arco-design/web-vue')['Switch']
ATable: typeof import('@arco-design/web-vue')['Table']
ATableColumn: typeof import('@arco-design/web-vue')['TableColumn']
ATabPane: typeof import('@arco-design/web-vue')['TabPane']
ATabs: typeof import('@arco-design/web-vue')['Tabs']
ATag: typeof import('@arco-design/web-vue')['Tag']
ATextarea: typeof import('@arco-design/web-vue')['Textarea']
ATooltip: typeof import('@arco-design/web-vue')['Tooltip']
ATree: typeof import('@arco-design/web-vue')['Tree']
ATreeSelect: typeof import('@arco-design/web-vue')['TreeSelect']
ATrigger: typeof import('@arco-design/web-vue')['Trigger']
ATypographyParagraph: typeof import('@arco-design/web-vue')['TypographyParagraph']
ATypographyText: typeof import('@arco-design/web-vue')['TypographyText']
ATypographyTitle: typeof import('@arco-design/web-vue')['TypographyTitle']
AUpload: typeof import('@arco-design/web-vue')['Upload']
Avatar: typeof import('./../components/Avatar/index.vue')['default']
AWatermark: typeof import('@arco-design/web-vue')['Watermark']
Breadcrumb: typeof import('./../components/Breadcrumb/index.vue')['default']
CellCopy: typeof import('./../components/CellCopy/index.vue')['default']
Chart: typeof import('./../components/Chart/index.vue')['default']
CronForm: typeof import('./../components/GenCron/CronForm/index.vue')['default']
CronModal: typeof import('./../components/GenCron/CronModal/index.vue')['default']
DateRangePicker: typeof import('./../components/DateRangePicker/index.vue')['default']
DayForm: typeof import('./../components/GenCron/CronForm/component/day-form.vue')['default']
FilePreview: typeof import('./../components/FilePreview/index.vue')['default']
GiCellAvatar: typeof import('./../components/GiCell/GiCellAvatar.vue')['default']
GiCellGender: typeof import('./../components/GiCell/GiCellGender.vue')['default']
GiCellStatus: typeof import('./../components/GiCell/GiCellStatus.vue')['default']
GiCellTag: typeof import('./../components/GiCell/GiCellTag.vue')['default']
GiCellTags: typeof import('./../components/GiCell/GiCellTags.vue')['default']
GiCodeView: typeof import('./../components/GiCodeView/index.vue')['default']
GiDot: typeof import('./../components/GiDot/index.tsx')['default']
GiEditTable: typeof import('./../components/GiEditTable/GiEditTable.vue')['default']
GiFlexibleBox: typeof import('./../components/GiFlexibleBox/index.vue')['default']
GiFooter: typeof import('./../components/GiFooter/index.vue')['default']
GiForm: typeof import('./../components/GiForm/src/GiForm.vue')['default']
GiIconSelector: typeof import('./../components/GiIconSelector/index.vue')['default']
GiIframe: typeof import('./../components/GiIframe/index.vue')['default']
GiLeftRightPane: typeof import('./../components/GiLeftRightPane/index.vue')['default']
GiOption: typeof import('./../components/GiOption/index.vue')['default']
GiOptionItem: typeof import('./../components/GiOptionItem/index.vue')['default']
GiOverFlowTags: typeof import('./../components/GiOverFlowTags/index.vue')['default']
GiSpace: typeof import('./../components/GiSpace/index.vue')['default']
GiSplitButton: typeof import('./../components/GiSplitButton/index.vue')['default']
GiSplitPane: typeof import('./../components/GiSplitPane/index.vue')['default']
GiSplitPaneFlexibleBox: typeof import('./../components/GiSplitPane/components/GiSplitPaneFlexibleBox.vue')['default']
GiSvgIcon: typeof import('./../components/GiSvgIcon/index.vue')['default']
GiTable: typeof import('./../components/GiTable/index.vue')['default']
GiTag: typeof import('./../components/GiTag/index.tsx')['default']
GiThemeBtn: typeof import('./../components/GiThemeBtn/index.vue')['default']
HourForm: typeof import('./../components/GenCron/CronForm/component/hour-form.vue')['default']
Icon403: typeof import('./../components/icons/Icon403.vue')['default']
Icon404: typeof import('./../components/icons/Icon404.vue')['default']
Icon500: typeof import('./../components/icons/Icon500.vue')['default']
IconBorders: typeof import('./../components/icons/IconBorders.vue')['default']
IconTableSize: typeof import('./../components/icons/IconTableSize.vue')['default']
IconTreeAdd: typeof import('./../components/icons/IconTreeAdd.vue')['default']
IconTreeReduce: typeof import('./../components/icons/IconTreeReduce.vue')['default']
JsonPretty: typeof import('./../components/JsonPretty/index.vue')['default']
MinuteForm: typeof import('./../components/GenCron/CronForm/component/minute-form.vue')['default']
MonthForm: typeof import('./../components/GenCron/CronForm/component/month-form.vue')['default']
ParentView: typeof import('./../components/ParentView/index.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SecondForm: typeof import('./../components/GenCron/CronForm/component/second-form.vue')['default']
SplitPanel: typeof import('./../components/SplitPanel/index.vue')['default']
TextCopy: typeof import('./../components/TextCopy/index.vue')['default']
ToggleDark: typeof import('./../components/ToggleDark/index.vue')['default']
UserSelect: typeof import('./../components/UserSelect/index.vue')['default']
Verify: typeof import('./../components/Verify/index.vue')['default']
VerifyPoints: typeof import('./../components/Verify/Verify/VerifyPoints.vue')['default']
VerifySlide: typeof import('./../components/Verify/Verify/VerifySlide.vue')['default']
WeekForm: typeof import('./../components/GenCron/CronForm/component/week-form.vue')['default']
YearForm: typeof import('./../components/GenCron/CronForm/component/year-form.vue')['default']
}
}

View File

@@ -23,88 +23,160 @@
</a-form-item>
</div>
<div class="form-grid-item">
<a-form-item label="生产批次" required>
<a-input v-model="formData.productionBatch" placeholder="请输入生产批次" />
<a-form-item label="生产批次">
<a-input v-model="formData.batch" placeholder="未获取到生产批次" :disabled="true" />
</a-form-item>
</div>
</div>
<div class="form-actions">
<a-button type="primary" @click="generateLabel" :disabled="!formData.productionBatch">生成标签</a-button>
</div>
</a-form>
<div class="form-actions">
<a-button type="primary" @click="generateDetailLabel">明细标签</a-button>
<a-button type="primary" @click="generateOverallLabel">整体标签</a-button>
</div>
</div>
<!-- 标签预览 -->
<div v-if="labelData.partName" class="label-preview-section">
<!-- <div class="label-preview-section">-->
<div v-if="labelDataList.length > 0 || labelData.partName" class="label-preview-section">
<h3>标签预览</h3>
<div class="label-container" ref="labelContainer">
<div class="label" v-for="index in 1" :key="index">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">{{ labelData.partName }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">{{ labelData.productionDate }}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img v-if="labelData.qrCodeImage" :src="labelData.qrCodeImage" alt="QR Code" />
<div v-else class="loading">生成二维码中...</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">{{ labelData.partNumber }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">{{ labelData.totalCount }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">{{ labelData.totalCalculatedWeight }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">{{ labelData.packingSignature || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">{{ labelData.totalWeight || '' }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">{{ labelData.inspectionSignature || '' }}</div>
</div>
</td>
</tr>
</table>
</div>
<!-- 明细标签显示多个标签 -->
<template v-if="labelDataList.length > 0">
<div class="label" v-for="(item, index) in labelDataList" :key="index">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">{{ item.partName }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">{{ item.productionDate }}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img v-if="item.qrCodeImage" :src="item.qrCodeImage" alt="QR Code" />
<div class="mark-number">{{ item.mark || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">{{ item.partNumber }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">{{ item.totalCount }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">{{ item.totalCalculatedWeight }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">{{ item.packingSignature || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">{{ item.totalWeight || '' }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">{{ item.inspectionSignature || '' }}</div>
</div>
</td>
</tr>
</table>
</div>
</template>
<!-- 整体标签显示单个标签 -->
<template v-else>
<div class="label">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">{{ labelData.partName }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">{{ labelData.productionDate }}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img v-if="labelData.qrCodeImage" :src="labelData.qrCodeImage" alt="QR Code" />
<div class="mark-number">{{ labelData.mark || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">{{ labelData.partNumber }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">{{ labelData.totalCount }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">{{ labelData.totalCalculatedWeight }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">{{ labelData.packingSignature || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">{{ labelData.totalWeight || '' }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">{{ labelData.inspectionSignature || '' }}</div>
</div>
</td>
</tr>
</table>
</div>
</template>
</div>
<div class="label-actions">
<a-button type="primary" @click="printLabel">打印标签</a-button>
@@ -118,7 +190,7 @@
import { ref, reactive, nextTick, onMounted } from 'vue'
import { Message } from '@arco-design/web-vue'
import { useRoute } from 'vue-router'
import {getWorkOrder} from "@/apis/workOrder/workOrder"
import {getWorkOrder, type WorkOrderInfoResp} from "@/apis/workOrder/workOrder"
import QRCode from 'qrcode';
const route = useRoute()
@@ -132,11 +204,28 @@ const formData = reactive({
totalCalculatedWeight: '',
totalWeight: '',
totalCount: '',
productionBatch: '',
batch: '',
mark: '',
qrCodeData: '',
workOrderInfos: Array<WorkOrderInfoResp>(),
})
// 标签数据
// 标签数据数组
const labelDataList = reactive<Array<{
partName: string
partNumber: string
totalCalculatedWeight: string
totalWeight: string
productionDate: string
totalCount: string
packingSignature: string
inspectionSignature: string
qrCodeData: string
qrCodeImage: string
mark: string
}>>([])
// 标签数据(用于整体标签)
const labelData = reactive({
partName: '',
partNumber: '',
@@ -148,6 +237,7 @@ const labelData = reactive({
inspectionSignature: '',
qrCodeData: '',
qrCodeImage: '',
mark: '',
})
// 标签容器引用
@@ -170,10 +260,16 @@ const generateQRCode = async (data: string) => {
}
}
// 生成标签
const generateLabel = async () => {
if (!formData.productionBatch) {
Message.error('请输入生产批次')
// 生成明细标签
const generateDetailLabel = async () => {
if (!formData.workOrderInfos || formData.workOrderInfos.length === 0) {
Message.error('未获取到工单明细信息')
return
}
if (!formData.batch) {
console.log("11111", formData.batch);
Message.error('未获取到批次信息')
return
}
if (!formData.materialName) {
@@ -182,6 +278,9 @@ const generateLabel = async () => {
}
try {
// 清空之前的标签数据
labelDataList.length = 0
// 格式化生产日期为 yyyyMMddHHmm 格式
const now = new Date()
const formattedDate = now.getFullYear().toString() +
@@ -192,10 +291,69 @@ const generateLabel = async () => {
const formattedDate2 = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0');
String(now.getDate()).padStart(2, '0')
// 为每个工单明细生成一个标签
for (const workOrderInfo of formData.workOrderInfos) {
// 计算二维码数据
const orderNo = formData.orderNo + workOrderInfo.id;
const qrCodeData = `10#${formData.materialName}$11#9DP$12#${formData.batch}$17#${workOrderInfo.quantity}$20#${formattedDate2}$31#${orderNo}$DY`
// 生成二维码图片
const qrCodeImage = await generateQRCode(qrCodeData)
// 添加标签数据
labelDataList.push({
partName: formData.materialName || '',
partNumber: formData.encoding || '',
totalCalculatedWeight: workOrderInfo.calculatedWeight || '',
totalWeight: workOrderInfo.weight || '',
productionDate: formattedDate,
totalCount: workOrderInfo.quantity || '',
packingSignature: '',
inspectionSignature: '',
qrCodeData: qrCodeData,
qrCodeImage: qrCodeImage,
mark: formData.mark || '',
})
}
Message.success(`成功生成 ${labelDataList.length} 个明细标签`)
} catch (error) {
console.error('生成明细标签失败:', error)
Message.error('生成明细标签失败')
}
}
// 生成整体标签
const generateOverallLabel = async () => {
if (!formData.batch) {
Message.error('未获取到批次信息')
return
}
if (!formData.materialName) {
Message.error('未获取到物料信息')
return
}
try {
// 清空明细标签数据
labelDataList.length = 0
// 格式化生产日期为 yyyyMMddHHmm 格式
const now = new Date()
const formattedDate = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0') +
String(now.getHours()).padStart(2, '0') +
String(now.getMinutes()).padStart(2, '0')
const formattedDate2 = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0')
// 计算二维码数据
const qrCodeData = `10#${formData.materialName}$11#9DP$12#${formData.productionBatch}$17#${formData.totalCount}$20#${formattedDate2}$31#${formData.orderNo}$DY`
const qrCodeData = `10#${formData.materialName}$11#9DP$12#${formData.batch}$17#${formData.totalCount}$20#${formattedDate2}$31#${formData.orderNo}$DY`
// 生成二维码图片
const qrCodeImage = await generateQRCode(qrCodeData)
@@ -211,7 +369,8 @@ const generateLabel = async () => {
packingSignature: '',
inspectionSignature: '',
qrCodeData: qrCodeData,
qrCodeImage: qrCodeImage
qrCodeImage: qrCodeImage,
mark: formData.mark || '',
})
Message.success('标签生成成功')
@@ -233,16 +392,16 @@ onMounted(() => {
formData.encoding = res.data.encoding
formData.materialName = res.data.materialName
formData.orderNo = res.data.orderNo
formData.batch = res.data.batch
formData.totalCalculatedWeight = res.data.totalCalculatedWeight
formData.totalWeight = res.data.totalWeight
formData.totalCount = res.data.totalCount
formData.workOrderInfos = res.data.workOrderInfos
formData.mark = res.data.mark
} else {
Message.error('获取详情失败')
}
});
// 自动生成标签
generateLabel()
}
})
@@ -253,7 +412,81 @@ const printLabel = async () => {
// 创建打印窗口
const printWindow = window.open('', '_blank')
if (printWindow) {
// 直接构建打印内容,确保二维码图片正确生成
// 判断是打印明细标签还是整体标签
const isDetailLabels = labelDataList.length > 0
const labelsToPrint = isDetailLabels ? labelDataList : [labelData]
// 生成标签HTML
const labelsHTML = labelsToPrint.map(item => `
<div class="label">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">${item.partName}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">${item.productionDate}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img src="${item.qrCodeImage}" alt="QR Code" />
<div class="mark-number">${item.mark || ''}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">${item.partNumber}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">${item.totalCount}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">${item.totalCalculatedWeight}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">${item.packingSignature || ''}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">${item.totalWeight || ''}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">${item.inspectionSignature || ''}</div>
</div>
</td>
</tr>
</table>
</div>
`).join('')
// 构建打印内容
const printHTML = `
<html>
<head>
@@ -269,76 +502,13 @@ const printLabel = async () => {
.label-field { font-size: 7pt; font-weight: bold; margin-right: 2mm; min-width: 25pt; }
.label-value { font-size: 7pt; flex: 1; }
.qr-code img { width: 20mm; height: 20mm; margin: 1mm 0; }
.mark-number { font-size: 7pt; margin-top: 1mm; text-align: center; }
.serial-number { font-size: 7pt; margin-top: 1mm; }
</style>
</head>
<body>
<div class="label-container">
<div class="label">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">${labelData.partName}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">${labelData.productionDate}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img src="${labelData.qrCodeImage}" alt="QR Code" />
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">${labelData.partNumber}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">${labelData.totalCount}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">${labelData.totalCalculatedWeight}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">${labelData.packingSignature || ''}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">${labelData.totalWeight || ''}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">${labelData.inspectionSignature || ''}</div>
</div>
</td>
</tr>
</table>
</div>
${labelsHTML}
</div>
</body>
</html>
@@ -399,6 +569,7 @@ defineOptions({ name: 'print' })
margin-top: 20px;
display: flex;
justify-content: center;
gap: 20px;
}
/* 标签预览 */
@@ -418,9 +589,9 @@ defineOptions({ name: 'print' })
.label-container {
display: flex;
flex-wrap: wrap;
flex-direction: column;
gap: 20px;
justify-content: center;
align-items: center;
margin-bottom: 20px;
}
@@ -465,6 +636,7 @@ defineOptions({ name: 'print' })
.label-value {
font-size: 12px;
font-weight: bold;
flex: 1;
}
@@ -484,6 +656,13 @@ defineOptions({ name: 'print' })
color: #666;
}
.mark-number {
font-size: 10px;
margin-top: 5px;
text-align: center;
font-weight: bold;
}
.serial-number {
font-size: 12px;
margin-top: 5px;

View File

@@ -91,6 +91,15 @@ const columns: ColumnItem[] = reactive([
type: 'input',
span: 24,
},
{
label: '标记号',
field: 'mark',
type: 'input',
span: 24,
props: {
maxLength: 25,
},
},
{
label: '灯光等级',
field: 'lightLevel',

View File

@@ -20,6 +20,8 @@
<template #toolbar-left>
<a-input-search v-model="queryForm.materialName" placeholder="请输入物料名称" allow-clear @search="search" />
<a-input-search v-model="queryForm.encoding" placeholder="请输入物料编码" allow-clear @search="search" />
<a-input-search v-model="queryForm.batch" placeholder="请输入批次" allow-clear @search="search" />
<a-input-search v-model="queryForm.mark" placeholder="请输入标记号" allow-clear @search="search" />
<a-button @click="reset">
<template #icon><icon-refresh /></template>
<template #default>重置</template>
@@ -108,6 +110,8 @@ interface MaterialInfoRespWithStatus extends MaterialInfoResp {
const queryForm = reactive<MaterialInfoQuery>({
materialName: undefined,
encoding: undefined,
batch: undefined,
mark: undefined,
sort: ['mi.id,desc'],
})
@@ -128,6 +132,7 @@ const columns = ref<TableInstanceColumns[]>([
{ title: '物料单位重量(g)', dataIndex: 'unitWeight', slotName: 'unitWeight' },
{ title: '物料品类', dataIndex: 'typeName' },
{ title: '批次', dataIndex: 'batch' },
{ title: '标记号', dataIndex: 'mark' },
{ title: '物料直径', dataIndex: 'materialSpec', slotName: 'materialSpec', show: false },
{ title: '物料颜色', dataIndex: 'color', slotName: 'color', show: false },
{ title: '物料流程', dataIndex: 'materialProcess', slotName: 'materialProcess' },

View File

@@ -0,0 +1,664 @@
<template>
<div class="label-print-container">
<div class="form-section">
<a-form :model="formData" layout="vertical">
<div class="form-grid">
<div class="form-grid-item">
<a-form-item label="物料名称">
<a-input v-model="formData.materialName" placeholder="未获取到物料名称" :disabled="true" />
</a-form-item>
</div>
<div class="form-grid-item">
<a-form-item label="物料编码">
<a-input v-model="formData.encoding" placeholder="未获取到物料编码" :disabled="true" />
</a-form-item>
</div>
<div class="form-grid-item">
<a-form-item label="工单编号">
<a-input v-model="formData.orderNo" placeholder="未获取到工单编号" :disabled="true" />
</a-form-item>
</div>
<div class="form-grid-item">
<a-form-item label="生产批次">
<a-input v-model="formData.batch" placeholder="未获取到生产批次" :disabled="true" />
</a-form-item>
</div>
</div>
</a-form>
<div class="form-actions">
<a-button @click="handlePrevious">继续称重</a-button>
<a-button type="primary" @click="generateDetailLabel">明细标签</a-button>
<a-button type="primary" @click="generateOverallLabel">整体标签</a-button>
</div>
</div>
<div v-if="labelDataList.length > 0 || labelData.partName" class="label-preview-section">
<h3>标签预览</h3>
<div class="label-container" ref="labelContainer">
<template v-if="labelDataList.length > 0">
<div class="label" v-for="(item, index) in labelDataList" :key="index">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">{{ item.partName }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">{{ item.productionDate }}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img v-if="item.qrCodeImage" :src="item.qrCodeImage" alt="QR Code" />
<div class="mark-number">{{ item.mark || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">{{ item.partNumber }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">{{ item.totalCount }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">{{ item.totalCalculatedWeight }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">{{ item.packingSignature || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">{{ item.totalWeight || '' }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">{{ item.inspectionSignature || '' }}</div>
</div>
</td>
</tr>
</table>
</div>
</template>
<template v-else>
<div class="label">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">{{ labelData.partName }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">{{ labelData.productionDate }}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img v-if="labelData.qrCodeImage" :src="labelData.qrCodeImage" alt="QR Code" />
<div class="mark-number">{{ labelData.mark || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">{{ labelData.partNumber }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">{{ labelData.totalCount }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">{{ labelData.totalCalculatedWeight }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">{{ labelData.packingSignature || '' }}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">{{ labelData.totalWeight || '' }}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">{{ labelData.inspectionSignature || '' }}</div>
</div>
</td>
</tr>
</table>
</div>
</template>
</div>
<div class="label-actions">
<a-button type="primary" @click="printLabel">打印标签</a-button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, nextTick, onMounted, watch } from 'vue'
import { Message } from '@arco-design/web-vue'
import { getWorkOrder, type WorkOrderInfoResp } from "@/apis/workOrder/workOrder"
import QRCode from 'qrcode';
const emit = defineEmits<{
previous: []
}>()
interface LabelPrintProps {
workerOrderId?: string
}
const props = withDefaults(defineProps<LabelPrintProps>(), {
workerOrderId: ''
})
const formData = reactive({
workerOrderId: '',
encoding: '',
materialName: '',
orderNo: '',
totalCalculatedWeight: '',
totalWeight: '',
totalCount: '',
batch: '',
mark: '',
qrCodeData: '',
workOrderInfos: Array<WorkOrderInfoResp>(),
})
const labelDataList = reactive<Array<{
partName: string
partNumber: string
totalCalculatedWeight: string
totalWeight: string
productionDate: string
totalCount: string
packingSignature: string
inspectionSignature: string
qrCodeData: string
qrCodeImage: string
mark: string
}>>([])
const labelData = reactive({
partName: '',
partNumber: '',
totalCalculatedWeight: '',
totalWeight: '',
productionDate: '',
totalCount: '',
packingSignature: '',
inspectionSignature: '',
qrCodeData: '',
qrCodeImage: '',
mark: '',
})
const labelContainer = ref<HTMLElement | null>(null)
const handlePrevious = () => {
emit('previous')
}
const fetchWorkOrderData = async (workerOrderId: string) => {
if (!workerOrderId) {
return
}
try {
const res = await getWorkOrder(workerOrderId)
if (res.code == '0') {
formData.encoding = res.data.encoding
formData.materialName = res.data.materialName
formData.orderNo = res.data.orderNo
formData.batch = res.data.batch
formData.totalCalculatedWeight = res.data.totalCalculatedWeight
formData.totalWeight = res.data.totalWeight
formData.totalCount = res.data.totalCount
formData.workOrderInfos = res.data.workOrderInfos
formData.mark = res.data.mark
} else {
Message.error('获取工单详情失败')
}
} catch (error) {
console.error('获取工单详情失败:', error)
Message.error('获取工单详情失败')
}
}
const generateQRCode = async (data: string) => {
try {
return await QRCode.toDataURL(data, {
width: 120,
margin: 1,
color: {
dark: '#000000',
light: '#FFFFFF'
}
})
} catch (error) {
console.error('生成二维码失败:', error)
return ''
}
}
const generateDetailLabel = async () => {
if (!formData.workOrderInfos || formData.workOrderInfos.length === 0) {
Message.error('未获取到工单明细信息')
return
}
if (!formData.batch) {
Message.error('未获取到批次信息')
return
}
if (!formData.materialName) {
Message.error('未获取到物料信息')
return
}
try {
labelDataList.length = 0
const now = new Date()
const formattedDate = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0') +
String(now.getHours()).padStart(2, '0') +
String(now.getMinutes()).padStart(2, '0')
const formattedDate2 = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0')
for (const workOrderInfo of formData.workOrderInfos) {
const orderNo = formData.orderNo + workOrderInfo.id;
const qrCodeData = `10#${formData.materialName}$11#9DP$12#${formData.batch}$17#${workOrderInfo.quantity}$20#${formattedDate2}$31#${orderNo}$DY`
const qrCodeImage = await generateQRCode(qrCodeData)
labelDataList.push({
partName: formData.materialName || '',
partNumber: formData.encoding || '',
totalCalculatedWeight: workOrderInfo.calculatedWeight || '',
totalWeight: workOrderInfo.weight || '',
productionDate: formattedDate,
totalCount: workOrderInfo.quantity || '',
packingSignature: '',
inspectionSignature: '',
qrCodeData: qrCodeData,
qrCodeImage: qrCodeImage,
mark: formData.mark || ''
})
}
Message.success(`成功生成 ${labelDataList.length} 个明细标签`)
} catch (error) {
console.error('生成明细标签失败:', error)
Message.error('生成明细标签失败')
}
}
const generateOverallLabel = async () => {
if (!formData.batch) {
Message.error('未获取到批次信息')
return
}
if (!formData.materialName) {
Message.error('未获取到物料信息')
return
}
try {
labelDataList.length = 0
const now = new Date()
const formattedDate = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0') +
String(now.getHours()).padStart(2, '0') +
String(now.getMinutes()).padStart(2, '0')
const formattedDate2 = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0')
const qrCodeData = `10#${formData.materialName}$11#9DP$12#${formData.batch}$17#${formData.totalCount}$20#${formattedDate2}$31#${formData.orderNo}$DY`
const qrCodeImage = await generateQRCode(qrCodeData)
Object.assign(labelData, {
partName: formData.materialName || '',
partNumber: formData.encoding || '',
totalCalculatedWeight: formData.totalCalculatedWeight || '',
totalWeight: formData.totalWeight || '',
productionDate: formattedDate,
totalCount: formData.totalCount || '',
packingSignature: '',
inspectionSignature: '',
qrCodeData: qrCodeData,
qrCodeImage: qrCodeImage,
mark: formData.mark || ''
})
Message.success('标签生成成功')
} catch (error) {
console.error('生成标签失败:', error)
Message.error('生成标签失败')
}
}
const printLabel = async () => {
await nextTick()
if (labelContainer.value) {
const printWindow = window.open('', '_blank')
if (printWindow) {
const isDetailLabels = labelDataList.length > 0
const labelsToPrint = isDetailLabels ? labelDataList : [labelData]
const labelsHTML = labelsToPrint.map(item => `
<div class="label">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">${item.partName}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">${item.productionDate}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img src="${item.qrCodeImage}" alt="QR Code" />
<div class="mark-number">${item.mark || ''}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">${item.partNumber}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">${item.totalCount}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">${item.totalCalculatedWeight}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">${item.packingSignature || ''}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">${item.totalWeight || ''}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">${item.inspectionSignature || ''}</div>
</div>
</td>
</tr>
</table>
</div>
`).join('')
const printHTML = `
<html>
<head>
<title>标签打印</title>
<style>
body { margin: 0; padding: 10mm; font-family: Arial, sans-serif; }
.label-container { display: flex; flex-wrap: wrap; gap: 10mm; justify-content: center; }
.label { width: 90mm; height: 38.5mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; }
.label-table { width: 100%; height: 100%; border-collapse: collapse; }
.label-cell { border: 1px solid #000; padding: 1mm; vertical-align: top; }
.qr-cell { width: 24mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
.label-row { display: flex; align-items: center; }
.label-field { font-size: 7pt; font-weight: bold; margin-right: 2mm; min-width: 25pt; }
.label-value { font-size: 7pt; flex: 1; }
.qr-code img { width: 20mm; height: 20mm; margin: 1mm 0; }
.mark-number { font-size: 7pt; margin-top: 1mm; text-align: center; }
.serial-number { font-size: 7pt; margin-top: 1mm; }
</style>
</head>
<body>
<div class="label-container">
${labelsHTML}
</div>
</body>
</html>
`
printWindow.document.write(printHTML)
printWindow.document.close()
printWindow.onload = () => {
setTimeout(() => {
printWindow.focus()
printWindow.print()
printWindow.close()
}, 500)
}
}
}
}
onMounted(() => {
if (props.workerOrderId) {
fetchWorkOrderData(props.workerOrderId)
}
})
watch(() => props.workerOrderId, (newWorkerOrderId) => {
if (newWorkerOrderId) {
fetchWorkOrderData(newWorkerOrderId)
}
})
defineExpose({
generateDetailLabel,
generateOverallLabel
})
defineOptions({ name: 'LabelPrint' })
</script>
<style scoped lang="scss">
.label-print-container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.page-title {
margin-bottom: 30px;
text-align: center;
color: #333;
}
.form-section {
background-color: var(--color-bg-2);
padding: 20px;
border-radius: 4px;
margin-bottom: 30px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.form-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 16px;
margin-bottom: 20px;
}
.form-grid-item {
width: 100%;
}
.mark-number {
font-size: 10px;
margin-top: 5px;
text-align: center;
font-weight: bold;
}
.form-actions {
margin-top: 20px;
display: flex;
justify-content: center;
gap: 20px;
}
.label-preview-section {
margin-top: 30px;
padding: 20px;
background-color: var(--color-bg-2);
border-radius: 4px;
}
.label-preview-section h3 {
margin: 0 0 20px 0;
font-size: 16px;
font-weight: bold;
text-align: center;
}
.label-container {
display: flex;
flex-direction: column;
gap: 20px;
align-items: center;
margin-bottom: 20px;
}
.label {
width: 450px;
height: 180px;
border: 1px solid #000;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
.label-table {
width: 100%;
height: 100%;
border-collapse: collapse;
}
.label-cell {
border: 1px solid #000;
padding: 5px;
vertical-align: top;
}
.qr-cell {
width: 120px;
text-align: center;
vertical-align: middle;
}
.label-row {
display: flex;
align-items: center;
}
.label-field {
font-size: 10pt;
font-weight: bold;
margin-right: 8px;
min-width: 35px;
}
.label-value {
font-size: 10pt;
flex: 1;
font-weight: bold;
}
.qr-code img {
width: 100px;
height: 100px;
margin: 5px 0;
}
.loading {
color: #999;
font-size: 12px;
}
.label-actions {
display: flex;
justify-content: center;
gap: 20px;
}
</style>

View File

@@ -129,13 +129,23 @@
<a-input v-model="formData.materialName" placeholder="物料名称" disabled />
</div>
</div>
<div class="form-row">
<div class="form-item">
<label>该物料重量范围:</label>
<a-input v-model="formData.weightRange" placeholder="该物料重量范围" disabled />
</div>
<div class="form-item">
<label>单位克重g:</label>
<a-input v-model="formData.unitWeight" placeholder="-" disabled />
</div>
</div>
<div class="form-row">
<div class="form-item">
<label>输入数量:</label>
<a-input-number :min="1" mode="button" v-model="inputQuantity" placeholder="请输入数量" @change="calculateWeight" />
</div>
<div class="form-item">
<label>当前数量:</label>
<label>称重数量:</label>
<a-input v-model="calculateNumber" placeholder="-" disabled/>
</div>
</div>
@@ -149,12 +159,7 @@
<a-input v-model="ahDeviceWeight" placeholder="-" disabled />
</div>
</div>
<div class="form-row">
<div class="form-item">
<label>该物料重量范围:</label>
<a-input v-model="formData.weightRange" placeholder="该物料重量范围" disabled />
</div>
</div>
<!-- 图片展示 -->
<div class="image-placeholder square-image">
@@ -204,6 +209,16 @@
</div>
</div>
<!-- 完成并打印页面 -->
<div v-else-if="activeStep === 3" class="step-content">
<LabelPrint
ref="labelPrintRef"
:worker-order-id="workOrderId"
@previous="handlePrevious2"
/>
</div>
<!-- 操作按钮 -->
<div class="action-buttons">
<a-button
@@ -246,16 +261,19 @@ import {
validateWeighing,
vmSend, weighAHStart, weighAHStop
} from '@/apis/weightManage/weightManage'
import {type WorkOrderResp, addWorkOrder} from '@/apis/workOrder/workOrder'
import {type WorkOrderResp, addWorkOrder, type WorkOrderInfoResp} from '@/apis/workOrder/workOrder'
import {getCaptureImage, getCheckStatus, getEnterWeighPage, getLeaveWeighPage } from "@/apis/weightManage/ys";
import {brightness, connect, disconnect} from "@/apis/weightManage/light";
import router from "@/router";
import type {TableInstanceColumns} from "@/components/GiTable/type";
import QRCode from 'qrcode';
import LabelPrint from './LabelPrint.vue';
defineOptions({ name: 'WeightManage' })
// 标签打印组件引用
const labelPrintRef = ref<InstanceType<typeof LabelPrint> | null>(null)
// 当前步骤
const activeStep = ref(1)
@@ -267,6 +285,7 @@ const formData = reactive({
materialName: '', // 物料名称
materialSpec: '', // 物料直径
batch: '', // 批次
mark: '', // 标记号
materialProcess: '', // 物料流程
unitWeight: 0, // 重量
photoUrl: '', // 样图URL
@@ -505,6 +524,7 @@ onBeforeUnmount(() => {
})
})
const workOrderId = ref('')
const workOrderResp = ref<WorkOrderResp>({
id: '',
title: '',
@@ -519,6 +539,8 @@ const workOrderResp = ref<WorkOrderResp>({
createUserString: '',
updateUserString: '',
totalCalculatedWeight: '',
batch: '',
mark: '',
workOrderInfos: [],
matchResult: 'failed',
qrCodeData: '',
@@ -528,7 +550,7 @@ const workOrderResp = ref<WorkOrderResp>({
const inputQuantity = ref()
const calculateNumber = ref()
// todo
const ahDeviceWeight = ref()
const ahDeviceWeight = ref('')
const calculatedWeight = ref('')
const weighingCount = ref(1)
@@ -544,7 +566,8 @@ const weighingList = ref([
// 称重表格列
const columns = ref<TableInstanceColumns[]>([
{ title: '序号', dataIndex: 'weightTime', key: 'weightTime',},
{ title: '数量', dataIndex: 'quantity', key: 'quantity', className: 'green-bg',},
{ title: '输入数量', dataIndex: 'quantity', key: 'quantity', className: 'green-bg',},
{ title: '称重数量', dataIndex: 'weightQuantity', key: 'weightQuantity', className: 'green-bg',},
{ title: '称重重量(g)', dataIndex: 'weight', key: 'weight', className: 'green-bg',},
{ title: '标准重量(g)', dataIndex: 'calculatedWeight', key: 'calculatedWeight',},
{ title: '抓图', dataIndex: 'imgUrl', key: 'imgUrl',slotName: 'imgUrl',},
@@ -635,6 +658,7 @@ const fetchMaterialData = async (code: string) => {
formData.unitWeight = res.data?.unitWeight || 0
formData.photoUrl = res.data?.photoUrl || ''
formData.batch = res.data?.batch || ''
formData.mark = res.data?.mark || ''
formData.weightRange = (res.data?.downFloatRatio ?? '-') + '% ~ ' + (res.data?.upFloatRatio ?? '-') + '%'
}
if(res.data && res.data.id) {
@@ -642,137 +666,6 @@ const fetchMaterialData = async (code: string) => {
}
}
// 生成二维码
const generateQRCode = async (data: string) => {
try {
return await QRCode.toDataURL(data, {
width: 120,
margin: 1,
color: {
dark: '#000000',
light: '#FFFFFF'
}
})
} catch (error) {
console.error('生成二维码失败:', error)
return ''
}
}
// 打印标签
const printLabel = async (labelData: any) => {
const printWindow = window.open('', '_blank')
if (printWindow) {
const printHTML = `
<html>
<head>
<title>标签打印</title>
<style>
body { margin: 0; padding: 10mm; font-family: Arial, sans-serif; }
.label-container { display: flex; flex-wrap: wrap; gap: 10mm; justify-content: center; }
.label { width: 90mm; height: 38.5mm; border: 1px solid #000; padding: 0; box-sizing: border-box; page-break-inside: avoid; }
.label-table { width: 100%; height: 100%; border-collapse: collapse; }
.label-cell { border: 1px solid #000; padding: 1mm; vertical-align: top; }
.qr-cell { width: 24mm; text-align: center; vertical-align: middle; border: 1px solid #000; }
.label-row { display: flex; align-items: center; }
.label-field { font-size: 7pt; font-weight: bold; margin-right: 2mm; min-width: 25pt; }
.label-value { font-size: 7pt; flex: 1; }
.qr-code img { width: 20mm; height: 20mm; margin: 1mm 0; }
</style>
</head>
<body>
<div class="label-container">
<div class="label">
<table class="label-table">
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件名称</div>
<div class="label-value">${labelData.partName}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">生产日期</div>
<div class="label-value">${labelData.productionDate}</div>
</div>
</td>
<td class="label-cell qr-cell" rowspan="4">
<div class="qr-code">
<img src="${labelData.qrCodeImage}" alt="QR Code" />
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">零件号</div>
<div class="label-value">${labelData.partNumber}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">数量</div>
<div class="label-value">${labelData.totalCount}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">标重(g)</div>
<div class="label-value">${labelData.totalCalculatedWeight}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">包装签字</div>
<div class="label-value">${labelData.packingSignature || ''}</div>
</div>
</td>
</tr>
<tr>
<td class="label-cell">
<div class="label-row">
<div class="label-field">实重(g)</div>
<div class="label-value">${labelData.totalWeight || ''}</div>
</div>
</td>
<td class="label-cell">
<div class="label-row">
<div class="label-field">检验签字</div>
<div class="label-value">${labelData.inspectionSignature || ''}</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
`
printWindow.document.write(printHTML)
printWindow.document.close()
printWindow.onload = () => {
setTimeout(() => {
printWindow.focus()
printWindow.print()
}, 500)
}
// 监听打印完成事件
printWindow.onafterprint = () => {
printWindow.close()
Message.success('打印成功,正在初始化称重管理页面...')
// 重新加载页面以初始化称重管理
window.location.reload()
}
}
}
// 处理下一步
const handleNext = async () => {
// 步骤2直接完成称重登记
@@ -789,64 +682,16 @@ const handleNext = async () => {
console.log('工单创建响应:', res)
if (res.code === '0') {
console.log('工单创建成功,准备生成并打印标签')
Notification.success({
title: '操作成功',
content: `工单创建成功!`,
})
workOrderResp.value.id = res.data?.id || ''
workOrderResp.value.matchResult = 'success'
workOrderResp.value.title = res.data?.title || ''
workOrderResp.value.orderNo = res.data?.orderNo || ''
workOrderResp.value.totalWeight = res.data?.totalWeight || ''
workOrderResp.value.totalCalculatedWeight = res.data?.totalCalculatedWeight || ''
workOrderResp.value.totalCount = res.data?.totalCount || ''
workOrderResp.value.materialName = formData.materialName || ''
workOrderResp.value.encoding = formData.encoding || ''
// 格式化生产日期为 yyyyMMddHHmm 格式
const now = new Date()
const formattedDate = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0') +
String(now.getHours()).padStart(2, '0') +
String(now.getMinutes()).padStart(2, '0')
const formattedDate2 = now.getFullYear().toString() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0')
// 使用物料批次作为生产批次
const productionBatch = formData.batch || ''
// 计算二维码数据
const qrCodeData = `10#${formData.encoding}$11#9DP$12#${productionBatch}$17#${workOrderResp.value.totalCount}$20#${formattedDate2}$31#${workOrderResp.value.orderNo}$DY`
// 生成二维码图片
const qrCodeImage = await generateQRCode(qrCodeData)
// 准备标签数据
const labelData = {
partName: formData.materialName || '',
partNumber: formData.encoding || '',
totalCalculatedWeight: workOrderResp.value.totalCalculatedWeight || '',
totalWeight: workOrderResp.value.totalWeight || '',
productionDate: formattedDate,
totalCount: workOrderResp.value.totalCount || '',
packingSignature: '',
inspectionSignature: '',
qrCodeData: qrCodeData,
qrCodeImage: qrCodeImage
}
// 直接打印标签
await printLabel(labelData)
workOrderId.value = res.data?.id || ''
activeStep.value++
} else {
console.error('工单创建失败,响应码:', res.code, '消息:', res.msg)
Message.error(res.msg || '创建工单失败')
}
} catch (error) {
console.error('创建工作订单失败:', error)
Message.error('创建工作订单失败')
}
return;
@@ -860,8 +705,17 @@ const handleNext = async () => {
return;
}
if (!formData.encoding) {
Message.error('未识别到物料!')
}
if (!formData.batch || formData.batch === '') {
Message.error('该物料没有批次,无法对比')
Message.error('该物料没有批次!')
return;
}
if (!formData.mark || formData.mark === '') {
Message.error('该物料没有标记号')
return;
}
@@ -871,10 +725,10 @@ const handleNext = async () => {
}
// 调用后端接口获取比对结果 // todo
const res = await vmSend(materialCode);
const res = await vmSend(formData.encoding);
// const res = {
// data: 'success',
// };
// data: 'success'
// }
if (res.data) {
compareMatchResult.value = res.data
if (res.data === 'success') {
@@ -905,52 +759,21 @@ const handlePrevious = () => {
}
}
// 继续称重
const handlePrevious2 = () => {
if (activeStep.value > 1) {
activeStep.value--
weighingList.value = []
}
}
// 打印
const onPrint = async () => {
// 跳转到标签打印页面,并传递数据
await router.push({
await router.replace({
path: '/print',
query: {
workerOrderId: workOrderResp.value.id,
}
})
}
// 返回第一步
const handleBackToFirst = () => {
// 重置所有数据
activeStep.value = 1
// 重置表单数据
formData.inputMaterialCode = ''
formData.id = ''
formData.encoding = ''
formData.materialName = ''
formData.materialSpec = ''
formData.unitWeight = 0
formData.photoUrl = ''
compareMatchResult.value = ''
// 重置称重登记页面数据
inputQuantity.value = ''
// todo
ahDeviceWeight.value = ''
calculatedWeight.value = ''
weighingCount.value = 1
// 清空称重列表
weighingList.value = []
// 重置工作订单响应数据
workOrderResp.value = {}
// 离开称重页面时关闭WebSocket连接
closeWebSocket()
// 回到第一步后自动聚焦到物料编码输入框
nextTick(() => {
if (materialCodeInput.value) {
materialCodeInput.value.focus()
workerOrderId: workOrderId.value,
}
})
}
@@ -986,18 +809,20 @@ const handleConfirm = async () => {
materialId: formData.id,
inputQuantity: inputQuantity.value,
ahDeviceWeight: ahDeviceWeight.value,
weightQuantity: calculateNumber.value,
}
// todo
const res = await validateWeighing(data);
// 然后处理错误信息
if (!res || !res.code) {
return;
}
if (res.data.code !== '200') {
if (res.data.code !== '501') {
if (res.data.code !== '502') {
playAudio('tooMany')
}
if (res.data.code !== '502') {
if (res.data.code !== '501') {
playAudio('tooLess')
}
Message.error(res.data.msg || '系统异常!');
@@ -1013,6 +838,7 @@ const handleConfirm = async () => {
quantity: inputQuantity.value,
weight: ahDeviceWeight.value,
calculatedWeight: calculatedWeight.value,
weightQuantity: calculateNumber.value,
imgUrl: '加载中...', // 先显示加载状态
}
@@ -1024,6 +850,7 @@ const handleConfirm = async () => {
// todo
ahDeviceWeight.value = ''
calculatedWeight.value = ''
calculateNumber.value = ''
weighingCount.value = weighingList.value.length + 1
// 调用手动抓图接口
@@ -1082,6 +909,7 @@ const establishWebSocket = () => {
const unitWeight = formData.unitWeight
if (!isNaN(weight) && !isNaN(unitWeight) && unitWeight > 0) {
calculateNumber.value = Math.floor(weight / unitWeight)
// calculateNumber.value = Math.round(weight / unitWeight)
} else {
calculateNumber.value = ''
}

View File

@@ -5,7 +5,7 @@
:data="dataList"
:columns="columns"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1600 }"
:scroll="{ x: '100%', y: '100%', minWidth: 1800 }"
:pagination="pagination"
:disabled-tools="['size']"
:disabled-column-keys="['name']"
@@ -20,6 +20,7 @@
<a-input-search v-model="queryForm.carNo" placeholder="请输入人员卡号" allow-clear @search="search" />
<a-input-search v-model="queryForm.orderNo" placeholder="请输入任务工单号" allow-clear @search="search" />
<a-input-search v-model="queryForm.materialName" placeholder="请输入物料名称" allow-clear @search="search" />
<a-input-search v-model="queryForm.batch" placeholder="请输入批次" allow-clear @search="search" />
<a-input-search v-model="queryForm.encoding" placeholder="请输入物料编码" allow-clear @search="search" />
<a-date-picker
v-model="queryForm.startDate"
@@ -88,7 +89,7 @@
row-key="id"
:data="detailData"
:columns="detailColumns"
:scroll="{ x: '100%', y: '100%', minWidth: 700 }"
:scroll="{ x: '100%', y: '100%', width: 800 }"
>
<template #imgUrl="{ record }">
<a-image :src="record.imgUrl" width="50" />
@@ -137,6 +138,7 @@ const queryForm = reactive<WorkOrderQuery>({
encoding: undefined,
userName: undefined,
carNo: undefined,
batch: undefined,
startDate: undefined,
endDate: undefined,
sort: ['w.id,desc']
@@ -170,6 +172,7 @@ const columns = ref<TableInstanceColumns[]>(processColumns([
{ title: '创建人', dataIndex: 'createUserString' },
{ title: '人员卡号', dataIndex: 'cardNo' },
{ title: '任务工单号', dataIndex: 'orderNo' },
{ title: '批次', dataIndex: 'batch' },
{ title: '物料图片', dataIndex: 'photoUrl', slotName: 'photoUrl', minWidth: 180, ellipsis: true, tooltip: true },
{ title: '物料名称', dataIndex: 'materialName' },
{ title: '物料编码', dataIndex: 'encoding' },
@@ -210,9 +213,10 @@ const detailData = ref<any[]>([])
const detailColumns = ref<TableInstanceColumns[]>([
{ title: '称重次数', dataIndex: 'weightTime' },
{ title: '物料名称', dataIndex: 'materialName' },
{ title: '数量', dataIndex: 'quantity' },
{ title: '重量', dataIndex: 'weight', slotName: 'weight' },
{ title: '计算重量', dataIndex: 'calculatedWeight', slotName: 'calculatedWeight' },
{ title: '输入数量', dataIndex: 'quantity' },
{ title: '标准重量(g)', dataIndex: 'calculatedWeight', slotName: 'calculatedWeight' },
{ title: '称重数量', dataIndex: 'weightQuantity' },
{ title: '称重重量(g)', dataIndex: 'weight', slotName: 'weight' },
{ title: '抓拍图片', dataIndex: 'imgUrl', slotName: 'imgUrl' }
])