diff --git a/nladmin-ui/src/views/wms/basedata/structattr/index.vue b/nladmin-ui/src/views/wms/basedata/structattr/index.vue
index 5bf6cce4..e55b2a45 100644
--- a/nladmin-ui/src/views/wms/basedata/structattr/index.vue
+++ b/nladmin-ui/src/views/wms/basedata/structattr/index.vue
@@ -93,16 +93,17 @@
-
-
-
-
-
-
-
-
-
-
+
+ 标签打印
+
@@ -252,9 +253,7 @@
style="width: 100%;"
@selection-change="crud.selectionChangeHandler"
>
-
@@ -307,7 +306,13 @@
-
+
+
+
+
@@ -320,6 +325,7 @@ import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import OneCreateDialog from '@/views/wms/basedata/structattr/OneCreateDialog'
import crudSectattr from '@/views/wms/basedata/sectattr/sectattr'
+import QRCode from 'qrcode'
const defaultForm = {
struct_id: null,
@@ -402,6 +408,7 @@ export default {
}
return {
openOneCreateDialog: false,
+ printPreviewVisible: false,
sects: [],
invtypelist: [],
permission: {},
@@ -525,6 +532,68 @@ export default {
})
}).catch(() => {
})
+ },
+ createPrintPreview() {
+ const selections = this.crud.selections || []
+ if (selections.length === 0) {
+ this.$message.info('请先勾选需要打印标签的仓位')
+ return
+ }
+ this.printPreviewVisible = true
+ this.$nextTick(() => this.renderPrintContent(selections))
+ },
+ escapePrintValue(value) {
+ return String(value === undefined || value === null ? '' : value)
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''')
+ },
+ async renderPrintContent(rows) {
+ const iframe = this.$refs.printIframe
+ if (!iframe) return
+ const doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document)
+ if (!doc) {
+ setTimeout(() => this.renderPrintContent(rows), 100)
+ return
+ }
+ let html = '
'
+ for (const row of rows) {
+ const structCode = row.struct_code || ''
+ const imgSrc = await QRCode.toDataURL(structCode, { width: 300 })
+ html += '库位标签
'
+ html += '| 库位编码 | ' + this.escapePrintValue(structCode) + ' |  |
'
+ html += '| 库位名称 | ' + this.escapePrintValue(row.struct_name) + ' |
'
+ html += '| 所属库区 | ' + this.escapePrintValue(row.sect_name) + ' |
'
+ html += '| 所属仓库 | ' + this.escapePrintValue(row.stor_name) + ' |
'
+ html += '
'
+ }
+ html += ''
+ doc.open()
+ doc.write(html)
+ doc.close()
+ },
+ doPrint() {
+ const iframe = this.$refs.printIframe
+ if (!iframe) return
+ iframe.contentWindow.focus()
+ iframe.contentWindow.print()
+ },
+ closePrintPreview() {
+ this.printPreviewVisible = false
}
}
}