yh-hiprint 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -114,8 +114,27 @@ export default defineConfig({
114
114
 
115
115
  ```
116
116
 
117
+ ### 预览调用方法
118
+
119
+ ```javascript
120
+ // 如果是自己的组件中则需要自己引入,slw 脚本中是不需要自己引入的,slw已经处理
121
+ const hiprint = inject("$hiprint")
122
+
123
+ // 三个可选参数必须有一个
124
+ hirpint({
125
+ code: "xxxxxx", // 必选
126
+ params: {...}, // 可选
127
+ data: {...} | [{...},...], // 可选
128
+ isCustom: true | false, // 可选
129
+ })
130
+ ```
131
+
117
132
  ## 更新日志
118
133
 
134
+ ###### 2.2.0
135
+ - 修复 hiprint 方法升级后没有考虑到的问题。
136
+ - 增加 自定义输入数据 时,能够将数据存入缓存中。
137
+
119
138
  ###### 2.1.1
120
139
  - 升级 hiprint 方法,兼容打印预览的 data、isCustom 参数
121
140
 
@@ -47,7 +47,7 @@ let loading = ElLoading.service({
47
47
  function getData(query) {
48
48
  let { code, params, data, isCustom } = query;
49
49
  loading.setText("获取打印配置和数据");
50
- let reqParams = JSON.parse(params) || [];
50
+ let reqParams = params ? JSON.parse(params) : [];
51
51
 
52
52
  axios
53
53
  .request({
@@ -89,9 +89,11 @@ function getData(query) {
89
89
  if (isCustom === "1") {
90
90
  await ElMessageBox.prompt("在下面输入框中输入您给的自定义数据", "自定义数据", {
91
91
  inputType: "textarea",
92
+ inputValue: localStorage.hiprintCustomValue || null,
92
93
  }).then((e) => {
93
94
  try {
94
95
  hasData = true;
96
+ localStorage.hiprintCustomValue = e.value;
95
97
  list = JSON.parse(e.value);
96
98
  } catch (error) {
97
99
  try {
package/index.js CHANGED
@@ -14,7 +14,7 @@ export function cLog(string, isError = false) {
14
14
  }
15
15
  }
16
16
 
17
- export const hiprint = ({ code, params, data, isCustom }) => {
17
+ const hiprint = ({ code, params, data, isCustom }) => {
18
18
  let height = document.documentElement.clientHeight;
19
19
  let width = (document.documentElement.clientWidth - 1200) / 2;
20
20
  // 转换数组
@@ -22,8 +22,8 @@ export const hiprint = ({ code, params, data, isCustom }) => {
22
22
  if (typeof params !== "Array") {
23
23
  paramData = [params];
24
24
  }
25
- url = "/hiprint/#/preview?code=" + code;
26
- if (paramData) {
25
+ let url = "/hiprint/#/preview?code=" + code;
26
+ if (params) {
27
27
  url += `&params=${JSON.stringify(paramData)}`;
28
28
  }
29
29
  if (data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-hiprint",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "Hiprint for Vue3 by NoahLiu in ForceCon in Hunan Changesha",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",