yzp vor 1 Jahr
Ursprung
Commit
307dbe78a7

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

@@ -118,7 +118,6 @@ const openDialog = (row: any) => {
 	}
 	}
 	state.isShowDialog = true;
 	state.isShowDialog = true;
 	ruleFormRef.value?.resetFields();
 	ruleFormRef.value?.resetFields();
-
 	nextTick(() => {
 	nextTick(() => {
 		loadTemplate();
 		loadTemplate();
 	});
 	});
@@ -127,6 +126,7 @@ const openDialog = (row: any) => {
 // 加载模板
 // 加载模板
 const loadTemplate = () => {
 const loadTemplate = () => {
 	hiprintDesignRef.value?.hiprintTemplate.clear();
 	hiprintDesignRef.value?.hiprintTemplate.clear();
+	hiprintDesignRef.value?.setPrintDataDemo(state.ruleForm.printDataDemo);
 	if (JSON.stringify(state.ruleForm) !== '{}') {
 	if (JSON.stringify(state.ruleForm) !== '{}') {
 		hiprintDesignRef.value?.hiprintTemplate.update(JSON.parse(state.ruleForm.template));
 		hiprintDesignRef.value?.hiprintTemplate.update(JSON.parse(state.ruleForm.template));
 		hiprintDesignRef.value?.initPaper();
 		hiprintDesignRef.value?.initPaper();

+ 17 - 2
Web/src/views/system/print/component/hiprint/index.vue

@@ -91,7 +91,8 @@
 					</el-card>
 					</el-card>
 				</el-tab-pane>
 				</el-tab-pane>
 				<el-tab-pane label="测试数据">
 				<el-tab-pane label="测试数据">
-					<el-input v-model="printDataDemo" type="textarea" style="width: 100%" rows="35" placeholder="对整个文档的完整测试数据"></el-input>
+					<el-input v-model="printDataDemo" type="textarea" style="width: 100%" rows="30" placeholder="对整个文档的完整测试数据"></el-input>
+					<el-button @click="formatPrintDataDemo()" style="margin-top: 10px; width:100%" type="success">格式化字符串</el-button>
 				</el-tab-pane>
 				</el-tab-pane>
 			</el-tabs>
 			</el-tabs>
 		</el-col>
 		</el-col>
@@ -356,8 +357,22 @@ const initPaper = () => {
 	hiprintTemplate.value.setPaper(width, height); // 设置纸张大小
 	hiprintTemplate.value.setPaper(width, height); // 设置纸张大小
 };
 };
 
 
+// 设置预览测试数据
+const setPrintDataDemo = (strData: string|null|undefined) => {
+	printDataDemo.value = strData as string;
+}
+
+// 格式化打印测试数据
+const formatPrintDataDemo = () => {
+	try{
+		const obj = JSON.parse(printDataDemo.value);
+		printDataDemo.value = JSON.stringify(obj, null, 2);
+	} catch (e) {
+		ElMessageBox.alert("出错:" + e);
+	}
+}
 // 导出对象
 // 导出对象
-defineExpose({ hiprintTemplate, printDataDemo, initPaper, mode });
+defineExpose({ hiprintTemplate, printDataDemo, setPrintDataDemo, initPaper, mode });
 </script>
 </script>
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>