diff --git a/src/views/modules/shopOrder/shopOrder/shopOrder.vue b/src/views/modules/shopOrder/shopOrder/shopOrder.vue
index 2ca6262..b5e293f 100644
--- a/src/views/modules/shopOrder/shopOrder/shopOrder.vue
+++ b/src/views/modules/shopOrder/shopOrder/shopOrder.vue
@@ -57,6 +57,9 @@
{{ buttons.printButton }}
+
+ 外部打印
+
{{ buttons.cancelButton }}
@@ -675,6 +678,8 @@ export default {
},
data() {
return {
+ // 外部打印 JS 的地址配置,后续可修改此地址或提取到配置文件
+ externalPrintJsUrl: 'http://192.168.31.128:9000/print_js/rongxin/print_order.js',
visible: false,
queryTable: {
functionId: this.$route.meta.menuId,
@@ -1990,6 +1995,17 @@ export default {
}
},
mounted() {
+ // 页面加载时动态引入外部打印 JS,避免每次点击打印都去请求,也无需重包即可更新样式
+ const scriptId = 'external_print_js';
+ if (!document.getElementById(scriptId)) {
+ const script = document.createElement('script');
+ script.id = scriptId;
+ script.type = 'text/javascript';
+ // 添加时间戳防止缓存
+ script.src = this.externalPrintJsUrl + '?t=' + new Date().getTime();
+ document.head.appendChild(script);
+ }
+
this.$nextTick(() => {
this.height = window.innerHeight - 255;
})
@@ -2206,6 +2222,10 @@ export default {
//LODOP.SET_LICENSES("", "7B5624CC84E599D6B17F27DF40F4310C", "", "");
LODOP.NewPage();
LODOP.SET_PRINT_PAGESIZE(0, 2400, 1400, "");
+ //允许重选纸张方向
+ LODOP.SET_PRINT_MODE("RESELECT_ORIENT",true);
+ //允许重选纸张大小
+ LODOP.SET_PRINT_MODE("RESELECT_PAGESIZE",true);
LODOP.ADD_PRINT_LINE(102, 15, 103, 771, 0, 1);
LODOP.ADD_PRINT_TEXT(7, 257, 254, 50, this.orderInfo.orderNo);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 24);
@@ -2364,7 +2384,42 @@ export default {
}
},
- //提示是否取消订单
+ // 外部打印方法,使用在组件挂载时加载进来的 js 来处理打印逻辑
+ async printOrderExternal() {
+ if (!this.modelData.orderNo) {
+ return this.$message.warning(this.labels.pleaseSelectShopOrder)
+ }
+ // 获取订单数据
+ await this.getOrderInfo()
+ await this.getShopOrderSapSOBOM();
+ // 获取物料信息
+ const LODOP = this.getLodop()
+ if (LODOP && this.orderInfo) {
+ try {
+ // 检查外部文件是否正确挂载了对应的方法
+ if (typeof window.externalPrintShopOrder === 'function') {
+ const currentTime = this.dayjs().format('YYYY-MM-DD HH:mm:ss');
+ const userDisplay = this.$store.state.user.userDisplay;
+
+ // 调用外部的打印方法,将所需数据传递过去
+ window.externalPrintShopOrder(LODOP, this.orderInfo, this.orderSoBom, userDisplay, currentTime);
+ console.log("外部打印操作成功!")
+ } else {
+ this.$message.error('外部打印脚本加载失败,请检查网络或刷新页面重试');
+ }
+ } catch (error) {
+ console.error(error);
+ this.$message.error('调用外部打印方法出错');
+ }
+ }
+ },
+
+// 修改C-Lodop加载方式的示例,如果您的项目中存在类似的地方,可以参考修改
+// 旧方式可能类似:
+// script.src = 'http://localhost:8000/CLodopfuncs.js';
+
+// 新方式(升级为HTTPS并使用官网提供的域名方案):
+// script.src = 'https://localhost.lodop.net:8443/CLodopfuncs.js';
warnCancelOrderConfirm() {
//判断是否存在订单
if (!this.modelData.orderNo) {