yzp 1 jaar geleden
bovenliggende
commit
43aae1ec79

+ 8 - 2
Admin.NET/Admin.NET.Core/Entity/SysPrint.cs

@@ -1,4 +1,4 @@
-// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
+// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
 //
 // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
 //
@@ -65,5 +65,11 @@ public partial class SysPrint : EntityTenant
     /// </summary>
     [SugarColumn(ColumnDescription = "备注", Length = 128)]
     [MaxLength(128)]
-    public string? Remark { get; set; }
+    public string? Remark { get; set; }
+
+    /// <summary>
+    /// 打印预览测试数据
+    /// </summary>
+    [SugarColumn(ColumnDescription = "打印预览测试数据", ColumnDataType = StaticConfig.CodeFirst_BigString)]
+    public string ? PrintDataDemo { get; set; }
 }

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

@@ -9,15 +9,7 @@
 					</div>
 				</template>
 				<div style="margin: 0px 0px 0px 0px">
-					<el-tabs type="border-card">
-						<el-tab-pane label="属性">
-							<HiprintDesign :mode-index="mode" ref="hiprintDesignRef" />
-						</el-tab-pane>
-						<el-tab-pane label="测试数据">
-							<el-input type="textarea" style="width: 240px" rows="20"></el-input>
-						</el-tab-pane>
-					</el-tabs>
-					
+					<HiprintDesign :mode-index="mode" ref="hiprintDesignRef" />
 				</div>
 				<template #footer>
 					<span class="dialog-footer" style="margin-top: 10px">
@@ -164,6 +156,8 @@ const templateSubmit = async () => {
 	let templateJson=hiprintDesignRef.value?.hiprintTemplate.getJson();
 	templateJson.panels[0].index=hiprintDesignRef.value?.mode;
 	state.ruleForm.template = JSON.stringify(templateJson);
+	const printDataDemo = hiprintTemplate.value?.printDataDemo.value;
+	state.ruleForm.printData = printDataDemo;
 	if (state.ruleForm.id != undefined && state.ruleForm.id > 0) {
 		await getAPI(SysPrintApi).apiSysPrintUpdatePost(state.ruleForm);
 	} else {

+ 23 - 6
Web/src/views/system/print/component/hiprint/index.vue

@@ -82,11 +82,18 @@
 			</el-card>
 		</el-col>
 		<el-col :span="6" class="params_setting_container">
-			<el-card shadow="never" :body-style="{ padding: '0px' }">
-				<el-row class="hinnn-layout-sider">
-					<div id="PrintElementOptionSetting"></div>
-				</el-row>
-			</el-card>
+			<el-tabs type="border-card">
+				<el-tab-pane label="属性" style="height: auto">
+					<el-card shadow="never" :body-style="{ padding: '0px' }">
+						<el-row class="hinnn-layout-sider">
+							<div id="PrintElementOptionSetting"></div>
+						</el-row>
+					</el-card>
+				</el-tab-pane>
+				<el-tab-pane label="测试数据">
+					<el-input v-model="printDataDemo" type="textarea" style="width: 100%" rows="35" placeholder="对整个文档的完整测试数据"></el-input>
+				</el-tab-pane>
+			</el-tabs>
 		</el-col>
 	</el-row>
 
@@ -107,7 +114,7 @@ import 'vue-json-pretty/lib/styles.css';
 import { hiprint } from 'vue-plugin-hiprint';
 import providers from './providers';
 import PrintPreview from './preview.vue';
-import printData from './print-data';
+import printDataDefault from './print-data';
 
 var props = defineProps({
 	modeIndex: {
@@ -119,6 +126,7 @@ var props = defineProps({
 let hiprintTemplate = ref();
 let mode = ref(0); // 模板选择
 
+const printDataDemo = ref("");
 const preViewRef = ref();
 const state = reactive({
 	modeList: [] as any,
@@ -304,11 +312,20 @@ const otherPaper = () => {
 // 预览
 const preView = () => {
 	let { width } = state.curPaper;
+	let printData = null;
+	try {printData = JSON.parse(printDataDemo.value);}
+	catch(e){
+		console.log("出错:" + e)
+	}
+	if (printData == null) {
+		printData = printDataDefault;
+	}
 	preViewRef.value.showDialog(hiprintTemplate.value, printData, width);
 };
 // 直接打印
 const print = () => {
 	console.log('直接打印');
+	preView();
 };
 
 // 查看模板JSON