From dc0244f19e64d43972d9b654330c093e39544b8b Mon Sep 17 00:00:00 2001
From: 陈婷婷 <506607603@qq.com>
Date: 星期二, 23 十二月 2025 10:44:23 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-VUEUI
---
src/views/component/printList/barcode.vue | 123 ++++++++++++++++++++++++----------------
1 files changed, 73 insertions(+), 50 deletions(-)
diff --git a/src/views/component/printList/barcode.vue b/src/views/component/printList/barcode.vue
index a640440..ae0f5fc 100644
--- a/src/views/component/printList/barcode.vue
+++ b/src/views/component/printList/barcode.vue
@@ -1,13 +1,15 @@
<template>
- <div>
- <button @click="getTemp">鎵撳嵃</button>
- <div id="report_holder"> </div>
+ <div style="padding: 10px">
+ <el-button type="primary" @click="getTemp">鎵撳嵃</el-button>
+ <!-- <el-button type="primary" @click="getTempMeta">鑾峰彇鍏冩暟鎹�</el-button> -->
+ <div id="report_holder"></div>
</div>
</template>
<script>
-import PrintJS from 'print-js'
+import PrintJS from "print-js";
import axios from "axios";
+import { watch } from "vue";
export default {
name: "HBarPlanPrintWeb",
data() {
@@ -16,7 +18,7 @@
handleMessage: this.$route.query,
pageSize: {
width: 0,
- height: 0
+ height: 0,
},
reportViewer: null,
baseUrl: process.env.VUE_APP_BASE_API,
@@ -24,17 +26,28 @@
recordset: [],
},
grfPath: "",
-
- }
+ oriention: null,
+ };
},
async mounted() {
// 鑾峰彇 鎵撳嵃鐨勬暟鎹�
- await this.getPrintData()
-
+ await this.getPrintData();
+ // 鑾峰彇鎵撳嵃绾稿紶澶у皬
rubylong.grhtml5.barcodeURL = this.baseUrl + "/Utility/Barcode.ashx";
- this.reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", this.grfPath, this.json_data.recordset,
+ this.reportViewer = rubylong.grhtml5.insertReportViewer(
+ "report_holder",
+ this.grfPath,
+ this.json_data
);
this.reportViewer.start();
+ },
+ watch: {
+ // 鐩戝惉reportViewer鏄惁宸茬粡鏋勫缓瀹屾垚锛屾瀯寤哄畬鎴愬悗 鑾峰彇grf鏂囦欢鐨勬墦鍗伴〉闈㈠ぇ灏�
+ 'reportViewer.generated'(newVal, oldVal) {
+ if(newVal == true) {
+ this.getTempMeta()
+ }
+ },
},
methods: {
getUrlVars_JSON() {
@@ -45,6 +58,7 @@
return datajson;
},
async getPrintData() {
+ // 鍦ㄥぇ鎵归噺鎵撳嵃鐨勬椂鍊� url闀垮害鍙兘瓒単et鍏佽鐨勯暱搴� 鍚庣闇�鎸夐渶姹� 鏀规垚POST璇锋眰
let OpenTmp = decodeURIComponent(this.$route.query.OpenTmp);
let sql = "";
if (this.$route.query.Type == "Kf_SellOutBillList") {
@@ -56,6 +70,11 @@
"select * from h_v_IF_BarCodeBillList where hmainid in(" +
this.handleMessage.linterid.toString() +
") order by hmainid desc";
+ } else if (this.$route.query.Type == "HGy_BarCodeBillList") {
+ sql =
+ "select * from h_v_IF_BarCodeBillList where hmainid in(" +
+ this.handleMessage.linterid.toString() +
+ ") order by hmainid desc";
} else if (this.$route.query.Type == "HPOInStockBill") {
sql =
"select * from h_v_Sc_PrintMouldProdOutBillList where hmainid=" +
@@ -63,81 +82,85 @@
" order by hmainid";
} else if (this.$route.query.Type == "HGyStockPlaceBarCode") {
let condition = decodeURI(this.handleMessage.linterid.toString());
- sql = `SELECT
- CEILING(CAST(t.row_num AS FLOAT) / 2) AS orderid,
- MAX(CASE WHEN t.row_num % 2 = 1 THEN t.鏉$爜缂栧彿 END) AS 鏉$爜缂栧彿1,
- MAX(CASE WHEN t.row_num % 2 = 1 THEN t.浠撲綅鍚嶇О END) AS 浠撲綅鍚嶇О1,
- MAX(CASE WHEN t.row_num % 2 = 0 THEN t.鏉$爜缂栧彿 END) AS 鏉$爜缂栧彿2,
- MAX(CASE WHEN t.row_num % 2 = 0 THEN t.浠撲綅鍚嶇О END) AS 浠撲綅鍚嶇О2
- FROM (
- SELECT
- 鏉$爜缂栧彿, 浠撲綅鍚嶇О,
- ROW_NUMBER() OVER (ORDER BY t1.HItemID) AS row_num
- FROM h_v_IF_StockPlaceList t1 where 鏉$爜缂栧彿 in (${condition})
- ) AS t
- GROUP BY CEILING(CAST(t.row_num AS FLOAT) / 2)
- ORDER BY orderid;`;
+ condition = condition.split(',').map(e => `'${e}'`).join(',')
+ sql = `exec h_p_GetSPBarCode_Swell N'${condition}'`;
}
try{
- let res = await axios.get(this.baseURL + "/CommonModel/searchMethod", {
+ let res = await axios.get(this.baseUrl + "/CommonModel/searchMethod", {
params: {
sql: sql,
user: sessionStorage["HUserName"],
ModRightNameCheck: "",
// , "HSubID": data[i].hsubid
},
- })
+ });
// 灏� 娓叉煋鏁版嵁 鍜� 妯℃澘鍔犺浇鍒版湰鍦�
let result = res.data;
- this.json_data.recordset = result.data;
- this.grfPath = "./static/grf/" + OpenTmp + ".grf"
- console.log(this.json_data);
- }catch(err) {
+ this.json_data.recordset = result.data;
+ this.grfPath = "./static/grf/" + OpenTmp + ".grf";
+ console.log(this.json_data);
+ } catch (err) {
this.$modal.msgError("鎺ュ彛璇锋眰澶辫触!" + err);
}
-
+ },
+ getTempMeta() {
+ let grfMeta = JSON.parse(this.reportViewer.reportText);
+ console.log("grfMeta", grfMeta)
+ this.pageSize.width = grfMeta.Printer.Width * 10 + "mm";
+ this.pageSize.height = grfMeta.Printer.Height * 10 + "mm";
+ console.log("pageSize: ",this.pageSize)
+ this.oriention = grfMeta.Printer.Oriention.toLowerCase()
},
getTemp() {
// 瀵规瘡涓鎵撳嵃鐨勫璞℃坊鍔犲垎椤�
- let docs = document.querySelectorAll('[_grrecno]')
- this.pageSize.width = docs[0].offsetWidth
- this.pageSize.height = docs[0].offsetHeight
+ let docs = document.querySelectorAll("[_grrecno]");
+ // this.pageSize.width = docs[0].offsetWidth;
+ // this.pageSize.height = docs[0].offsetHeight;
docs.forEach((elem, index) => {
- elem.classList.add('printable')
- })
- let styles = document.querySelectorAll('[id^="_gridcss"]')
- this.styleList.push(...styles)
+ elem.classList.add("printable");
+ });
+ let styles = document.querySelectorAll('[id^="_gridcss"]');
+ this.styleList.push(...styles);
- this.execPrint()
+ this.execPrint();
},
execPrint() {
PrintJS({
- printable: 'report_holder',
+ printable: "report_holder",
scanStyles: false,
- type: 'html',
- style: this.styleList[0].innerText + ` @media print {
+ type: "html",
+ style:
+ this.styleList[0].innerText +
+ `
.printable {
page-break-inside: avoid;
page-break-after: always;
+ box-sizing: border-box !important; /* 鍐呰竟璺濅笉褰卞搷瀹介珮 */
}
@page {
- size: ${this.pageSize.width + 1}px ${this.pageSize.height + 1}px;
+ size: ${this.pageSize.width} ${this.pageSize.height};
margin: 0;
padding: 0;
}
+
+ table { border-collapse: collapse !important; }
* {
margin: 0;
padding: 0;
+ color: #000 !important;
+ opacity: 1 !important;
+ filter: none !important;
+ text-shadow: none !important;
+ -webkit-print-color-adjust: exact; /* 寮哄埗杩樺師棰滆壊锛堥伩鍏嶆贰鑹诧級 */
}
`,
- })
-
-
- }
- }
-}
+ });
+ },
+ },
+};
</script>
-<style></style>
\ No newline at end of file
+<style>
+</style>
--
Gitblit v1.9.1