Przeglądaj źródła

😎整理代码

zuohuaijun 1 rok temu
rodzic
commit
5bb5ae8241

+ 0 - 1
Admin.NET/Admin.NET.Core/Entity/SysPrint.cs

@@ -4,7 +4,6 @@
 //
 // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
 
-
 namespace Admin.NET.Core;
 
 /// <summary>

+ 3 - 2
Admin.NET/Admin.NET.Core/Enum/PrintTypeEnum.cs

@@ -4,8 +4,8 @@
 //
 // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
 
-
 namespace Admin.NET.Core;
+
 /// <summary>
 /// 打印类型枚举
 /// </summary>
@@ -17,9 +17,10 @@ public enum PrintTypeEnum
     /// </summary>
     [Description("浏览器打印")]
     Browser = 1,
+
     /// <summary>
     /// 浏览器打印
     /// </summary>
     [Description("客户端打印")]
     Client = 2,
-}
+}

+ 1 - 1
Web/src/views/system/print/component/editPrint.vue

@@ -57,7 +57,7 @@
 						</el-form-item>
 					</el-col>
 					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
-						<el-form-item label="客户端服务地址"  >
+						<el-form-item label="客户端服务地址">
 							<el-input v-model="state.ruleForm.clientServiceAddress" placeholder="客户端服务地址" clearable />
 						</el-form-item>
 					</el-col>

+ 21 - 23
Web/src/views/system/print/component/hiprint/preview.vue

@@ -17,12 +17,12 @@ const state = reactive({
 	waitShowPrinter: false,
 	width: 0, // 纸张宽 mm
 	printData: {}, // 打印数据
-	printType:1,//默认浏览器打印
-	printParam:{
-		printer:'',//打印机名称
-		title:'',//打印任务名称
-		color:false,// 是否打印颜色 默认 true
-		copies:1,//打印份数 默认 1
+	printType: 1, //默认浏览器打印
+	printParam: {
+		printer: '', //打印机名称
+		title: '', //打印任务名称
+		color: false, // 是否打印颜色 默认 true
+		copies: 1, //打印份数 默认 1
 	},
 	//打印参数
 	hiprintTemplate: {} as any,
@@ -30,14 +30,13 @@ const state = reactive({
 
 const previewContentRef = ref();
 
-const showDialog = (hiprintTemplate: any, printData: {}, width = 210,printType=1,printParam:{printer:'',title:'',color:false,copies:1}) => {
-
+const showDialog = (hiprintTemplate: any, printData: {}, width = 210, printType = 1, printParam: { printer: ''; title: ''; color: false; copies: 1 }) => {
 	state.dialogVisible = true;
 	state.width = width;
 	state.hiprintTemplate = hiprintTemplate;
 	state.printData = printData;
 	state.printParam = printParam;
-	state.printType=printType;
+	state.printType = printType;
 	nextTick(() => {
 		while (previewContentRef.value?.firstChild) {
 			previewContentRef.value.removeChild(previewContentRef.value.firstChild);
@@ -49,34 +48,33 @@ const showDialog = (hiprintTemplate: any, printData: {}, width = 210,printType=1
 
 const print = () => {
 	state.waitShowPrinter = true;
-	debugger
+	debugger;
 	// 判断是否已成功连接
-	if (state.printType==2) {
+	if (state.printType == 2) {
 		// 注意:连接是异步的
 		// 已连接
 		// 获取打印机列表
 		const printerList = state.hiprintTemplate.getPrinterList();
 
-		let sfcz= printerList.some((item)=>{
-			return item.name==state.printParam.printer;
-		})
-		if(!sfcz){
+		let sfcz = printerList.some((item) => {
+			return item.name == state.printParam.printer;
+		});
+		if (!sfcz) {
 			alert('打印机不存在');
-		}else{
+		} else {
 			// 直接打印 将使用系统设置的 默认打印机
-			state.hiprintTemplate.print2(state.printData,state.printParam);
+			state.hiprintTemplate.print2(state.printData, state.printParam);
 
 			// 发送任务到打印机成功
 			state.hiprintTemplate.on('printSuccess', function (e) {
-				state.waitShowPrinter=false;
-			})
+				state.waitShowPrinter = false;
+			});
 			// 发送任务到打印机失败
 			state.hiprintTemplate.on('printError', function (e) {
-				state.waitShowPrinter=false;
-				alert('打印失败:'+e);
-			})
+				state.waitShowPrinter = false;
+				alert('打印失败:' + e);
+			});
 		}
-		
 	} else {
 		state.hiprintTemplate.print(
 			state.printData,