yh-hiprint 2.6.13 → 2.6.15
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/HiprintDesigner.vue +670 -687
- package/config.json +399 -0
- package/doc.md +265 -0
- package/hiprintPreview.vue +132 -133
- package/hooks/useHipirntCanvas.ts +3 -0
- package/hooks/{useHiprint.js → useHiprint.ts} +115 -53
- package/hooks/useHiprintep.ts +0 -0
- package/index.ts +539 -0
- package/libs/index.js +2 -2
- package/libs/previewHiprint.ts +55 -0
- package/package.json +10 -4
- package/store/defaultPrintElement.ts +175 -0
- package/store/useHiprintStore.ts +92 -0
- package/types.ts +756 -0
- package/index.d.ts +0 -377
- package/index.js +0 -376
package/hiprintPreview.vue
CHANGED
|
@@ -11,165 +11,164 @@
|
|
|
11
11
|
sub-title="请求参数或者返回数据错误"></el-result>
|
|
12
12
|
</template>
|
|
13
13
|
<script setup>
|
|
14
|
-
import {ElLoading, ElResult, ElMessageBox} from 'element-plus';
|
|
15
|
-
import {onMounted, ref} from 'vue';
|
|
16
|
-
import {useRoute} from 'vue-router';
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import {getPrintTemplate} from 'yh-hiprint/libs/index.js';
|
|
14
|
+
import {ElLoading, ElResult, ElMessageBox} from 'element-plus';
|
|
15
|
+
import {onMounted, ref} from 'vue';
|
|
16
|
+
import {useRoute} from 'vue-router';
|
|
17
|
+
import {hiprint} from 'yh-hiprint';
|
|
18
|
+
import {getPrintTemplate} from 'yh-hiprint';
|
|
20
19
|
|
|
21
|
-
function getQuery() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
function getQuery() {
|
|
21
|
+
let query = {};
|
|
22
|
+
try {
|
|
23
|
+
location.hash
|
|
24
|
+
.split('?')[1]
|
|
25
|
+
.split('&')
|
|
26
|
+
.forEach((str) => {
|
|
27
|
+
let index = str.indexOf('=');
|
|
28
|
+
let key = str.substring(0, index);
|
|
29
|
+
let value = decodeURIComponent(str.substring(index + 1));
|
|
30
|
+
switch (key) {
|
|
31
|
+
case 'returnHtml':
|
|
32
|
+
value = value === '1';
|
|
33
|
+
break;
|
|
34
|
+
case 'isCustom':
|
|
35
|
+
value = value === '1';
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
query[key] = value;
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('hiprint Preview getQuery on error:', error);
|
|
42
|
+
}
|
|
43
|
+
return query;
|
|
43
44
|
}
|
|
44
|
-
return query;
|
|
45
|
-
}
|
|
46
45
|
|
|
47
|
-
onMounted(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
getData(query);
|
|
52
|
-
} else {
|
|
53
|
-
if (sessionStorage.printQuery) {
|
|
54
|
-
query = JSON.parse(sessionStorage.printQuery);
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
let query = getQuery();
|
|
48
|
+
if (query.code) {
|
|
49
|
+
sessionStorage.printQuery = JSON.stringify(query);
|
|
55
50
|
getData(query);
|
|
56
51
|
} else {
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
if (sessionStorage.printQuery) {
|
|
53
|
+
query = JSON.parse(sessionStorage.printQuery);
|
|
54
|
+
getData(query);
|
|
55
|
+
} else {
|
|
56
|
+
loading.close();
|
|
57
|
+
error.value = true;
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
window.addEventListener('afterprint', () => {
|
|
61
|
+
self.close();
|
|
62
|
+
});
|
|
63
63
|
});
|
|
64
|
-
});
|
|
65
64
|
|
|
66
|
-
const route = useRoute();
|
|
67
|
-
const success = ref(false);
|
|
68
|
-
const error = ref(false);
|
|
65
|
+
const route = useRoute();
|
|
66
|
+
const success = ref(false);
|
|
67
|
+
const error = ref(false);
|
|
69
68
|
|
|
70
|
-
let loading = ElLoading.service({
|
|
71
|
-
|
|
72
|
-
});
|
|
69
|
+
let loading = ElLoading.service({
|
|
70
|
+
text: '正在加载数据……',
|
|
71
|
+
});
|
|
73
72
|
|
|
74
|
-
async function getData(query) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
async function getData(query) {
|
|
74
|
+
let {code, params, data, isCustom, returnHtml} = query;
|
|
75
|
+
loading.setText('获取打印配置和数据');
|
|
76
|
+
let reqParams = params ? JSON.parse(params) : [];
|
|
77
|
+
try {
|
|
78
|
+
let res = await getPrintTemplate(code, reqParams);
|
|
79
|
+
loading.setText('格式化数据,初始化打印插件');
|
|
80
|
+
let {list, json} = res.data;
|
|
81
|
+
if (json) {
|
|
82
|
+
let hasData = false;
|
|
83
|
+
if (Array.isArray(list) && list.length > 0) {
|
|
84
|
+
list = list.map((item, index) => {
|
|
85
|
+
let printData = {};
|
|
86
|
+
let datas = Object.entries(item);
|
|
87
|
+
datas.forEach((arr) => {
|
|
88
|
+
if (Array.isArray(arr[1])) {
|
|
89
|
+
hasData = arr[1].length > 0;
|
|
90
|
+
printData[arr[0]] = arr[1];
|
|
91
|
+
} else {
|
|
92
|
+
if (arr[1] !== null) {
|
|
93
|
+
hasData = true;
|
|
94
|
+
let itemsEntries = Object.entries(arr[1]);
|
|
95
|
+
itemsEntries.forEach((cArr) => {
|
|
96
|
+
printData[`$${arr[0]}[${cArr[0]}]`] = cArr[1];
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return printData;
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
list = [];
|
|
105
|
+
}
|
|
106
|
+
let hiprintTemplate = new hiprint.PrintTemplate({template: JSON.parse(json)});
|
|
107
|
+
// 如若有本地数据,那么将本地数据替换远端数据。传入预览中。
|
|
108
|
+
if (isCustom === '1') {
|
|
109
|
+
await ElMessageBox.prompt('在下面输入框中输入您给的自定义数据', '自定义数据', {
|
|
110
|
+
inputType: 'textarea',
|
|
111
|
+
inputValue: localStorage.hiprintCustomValue || null,
|
|
112
|
+
}).then((e) => {
|
|
113
|
+
try {
|
|
114
|
+
hasData = true;
|
|
115
|
+
localStorage.hiprintCustomValue = e.value;
|
|
116
|
+
list = JSON.parse(e.value);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
try {
|
|
94
119
|
hasData = true;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
120
|
+
list = JSON.parse(data);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
hasData = false;
|
|
123
|
+
list = [];
|
|
99
124
|
}
|
|
100
125
|
}
|
|
101
126
|
});
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
list = [];
|
|
106
|
-
}
|
|
107
|
-
let hiprintTemplate = new hiprint.PrintTemplate({template: JSON.parse(json)});
|
|
108
|
-
// 如若有本地数据,那么将本地数据替换远端数据。传入预览中。
|
|
109
|
-
if (isCustom === '1') {
|
|
110
|
-
await ElMessageBox.prompt('在下面输入框中输入您给的自定义数据', '自定义数据', {
|
|
111
|
-
inputType: 'textarea',
|
|
112
|
-
inputValue: localStorage.hiprintCustomValue || null,
|
|
113
|
-
}).then((e) => {
|
|
127
|
+
} else if (data) {
|
|
114
128
|
try {
|
|
115
129
|
hasData = true;
|
|
116
|
-
|
|
117
|
-
list = JSON.parse(e.value);
|
|
130
|
+
list = JSON.parse(data);
|
|
118
131
|
} catch (error) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
list = JSON.parse(data);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
hasData = false;
|
|
124
|
-
list = [];
|
|
125
|
-
}
|
|
132
|
+
hasData = false;
|
|
133
|
+
list = [];
|
|
126
134
|
}
|
|
127
|
-
});
|
|
128
|
-
} else if (data) {
|
|
129
|
-
try {
|
|
130
|
-
hasData = true;
|
|
131
|
-
list = JSON.parse(data);
|
|
132
|
-
} catch (error) {
|
|
133
|
-
hasData = false;
|
|
134
|
-
list = [];
|
|
135
135
|
}
|
|
136
|
-
}
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
window.close();
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
document.body.innerHTML = '';
|
|
150
|
-
document.body.appendChild(html[0]);
|
|
151
|
-
if (hasData) {
|
|
152
|
-
setTimeout(() => {
|
|
153
|
-
window.print();
|
|
154
|
-
}, 1000);
|
|
155
|
-
} else {
|
|
156
|
-
ElMessageBox.alert('数据源没有数据,打印将取消').then(() => {
|
|
137
|
+
// 默认浏览器打印
|
|
138
|
+
let html = hiprintTemplate.getHtml(list);
|
|
139
|
+
if (opener && returnHtml && html[0]) {
|
|
140
|
+
opener.postMessage({
|
|
141
|
+
type: 'sendPrintHTML',
|
|
142
|
+
data: html[0].innerHTML,
|
|
143
|
+
});
|
|
144
|
+
ElMessageBox.alert('渲染完成!确认后返回系统').then(() => {
|
|
157
145
|
window.close();
|
|
158
146
|
});
|
|
147
|
+
} else {
|
|
148
|
+
document.body.innerHTML = '';
|
|
149
|
+
document.body.appendChild(html[0]);
|
|
150
|
+
if (hasData) {
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
window.print();
|
|
153
|
+
}, 1000);
|
|
154
|
+
} else {
|
|
155
|
+
ElMessageBox.alert('数据源没有数据,打印将取消').then(() => {
|
|
156
|
+
window.close();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
159
|
}
|
|
160
|
+
success.value = false;
|
|
161
|
+
} else {
|
|
162
|
+
error.value = true;
|
|
160
163
|
}
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error(error);
|
|
163
166
|
error.value = true;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} finally {
|
|
169
|
-
if (loading) {
|
|
170
|
-
loading.close();
|
|
167
|
+
} finally {
|
|
168
|
+
if (loading) {
|
|
169
|
+
loading.close();
|
|
170
|
+
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
}
|
|
174
173
|
</script>
|
|
175
174
|
<style lang="scss"></style>
|
|
@@ -1,17 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {hiprint as h, defaultElementTypeProvider as p} from '../libs/hiprint.bundle.js';
|
|
2
2
|
// 调用浏览器打印js
|
|
3
3
|
import '../libs/plugins/jquery.hiwprint.js';
|
|
4
4
|
// 默认配置
|
|
5
5
|
import '../libs/hiprint.config.js';
|
|
6
6
|
// 样式
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
7
|
+
import '../libs/css/hiprint.css';
|
|
8
|
+
import '../libs/css/print-lock.css';
|
|
9
|
+
import {ref, computed, watch, reactive, nextTick} from 'vue';
|
|
10
|
+
import useHiprintStore from '../store/useHiprintStore.js';
|
|
11
|
+
|
|
12
|
+
// 定义类型
|
|
13
|
+
interface PaperType {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface PaperDimensions {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface DataSourceItem {
|
|
24
|
+
columns?: string;
|
|
25
|
+
code: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface DataSourceOption {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface AxiosInstance {
|
|
36
|
+
request: (config: any) => Promise<any>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Response {
|
|
40
|
+
data: {
|
|
41
|
+
data?: {
|
|
42
|
+
sourceCodes?: string;
|
|
43
|
+
};
|
|
44
|
+
list: DataSourceItem[];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
10
47
|
|
|
11
48
|
export const hiprint = h;
|
|
12
49
|
export const defaultElementTypeProvider = p;
|
|
13
50
|
|
|
14
|
-
export function print
|
|
51
|
+
export function print(
|
|
52
|
+
provider: any = defaultElementTypeProvider,
|
|
53
|
+
template: any,
|
|
54
|
+
...args: any[]
|
|
55
|
+
): any {
|
|
15
56
|
hiprint.init({
|
|
16
57
|
providers: [new provider()],
|
|
17
58
|
});
|
|
@@ -22,7 +63,11 @@ export function print (provider = defaultElementTypeProvider, template, ...args)
|
|
|
22
63
|
return hiprintTemplate;
|
|
23
64
|
}
|
|
24
65
|
|
|
25
|
-
export function print2
|
|
66
|
+
export function print2(
|
|
67
|
+
provider: any = defaultElementTypeProvider,
|
|
68
|
+
template: any,
|
|
69
|
+
...args: any[]
|
|
70
|
+
): any {
|
|
26
71
|
hiprint.init({
|
|
27
72
|
providers: [new provider()],
|
|
28
73
|
});
|
|
@@ -33,9 +78,10 @@ export function print2 (provider = defaultElementTypeProvider, template, ...args
|
|
|
33
78
|
return hiprintTemplate;
|
|
34
79
|
}
|
|
35
80
|
|
|
36
|
-
export function usePaper
|
|
37
|
-
const
|
|
38
|
-
const
|
|
81
|
+
export function usePaper() {
|
|
82
|
+
const hiprintStore = useHiprintStore();
|
|
83
|
+
const paperType = ref<string>('A4');
|
|
84
|
+
const paperTypeName = computed((): string => {
|
|
39
85
|
const paperTypeObj = paperTypesObj.find((item) => item.value === paperType.value);
|
|
40
86
|
if (paperTypeObj) {
|
|
41
87
|
return paperTypeObj.label;
|
|
@@ -43,19 +89,19 @@ export function usePaper () {
|
|
|
43
89
|
return '自定义';
|
|
44
90
|
}
|
|
45
91
|
});
|
|
46
|
-
const paperWidth = ref(210);
|
|
47
|
-
const paperHeight = ref(296.6);
|
|
48
|
-
|
|
49
|
-
const paperTypesObj = reactive([
|
|
50
|
-
{
|
|
51
|
-
{
|
|
52
|
-
{
|
|
53
|
-
{
|
|
54
|
-
{
|
|
55
|
-
{
|
|
92
|
+
const paperWidth = ref<number>(210);
|
|
93
|
+
const paperHeight = ref<number>(296.6);
|
|
94
|
+
|
|
95
|
+
const paperTypesObj = reactive<PaperType[]>([
|
|
96
|
+
{label: 'A3', value: 'A3'},
|
|
97
|
+
{label: 'A4', value: 'A4'},
|
|
98
|
+
{label: 'A5', value: 'A5'},
|
|
99
|
+
{label: 'B3', value: 'B3'},
|
|
100
|
+
{label: 'B4', value: 'B4'},
|
|
101
|
+
{label: 'B5', value: 'B5'},
|
|
56
102
|
]);
|
|
57
103
|
|
|
58
|
-
const paperTypes = {
|
|
104
|
+
const paperTypes: Record<string, PaperDimensions> = {
|
|
59
105
|
A3: {
|
|
60
106
|
width: 420,
|
|
61
107
|
height: 297,
|
|
@@ -82,11 +128,12 @@ export function usePaper () {
|
|
|
82
128
|
},
|
|
83
129
|
};
|
|
84
130
|
|
|
85
|
-
function setPaper
|
|
131
|
+
function setPaper(type: string, callback: () => void): void {
|
|
86
132
|
if (type !== 'other') {
|
|
87
|
-
|
|
133
|
+
const {width, height} = paperTypes[type];
|
|
88
134
|
paperWidth.value = width;
|
|
89
135
|
paperHeight.value = height;
|
|
136
|
+
hiprintStore.setPaperOption(width, height);
|
|
90
137
|
}
|
|
91
138
|
callback();
|
|
92
139
|
}
|
|
@@ -121,22 +168,22 @@ export function usePaper () {
|
|
|
121
168
|
};
|
|
122
169
|
}
|
|
123
170
|
|
|
124
|
-
export function useScale (
|
|
125
|
-
const scaleValue = ref(1);
|
|
126
|
-
const scalePercentage = computed(() => {
|
|
171
|
+
export function useScale(callback: () => void) {
|
|
172
|
+
const scaleValue = ref<number>(1);
|
|
173
|
+
const scalePercentage = computed((): string => {
|
|
127
174
|
return `${(scaleValue.value * 100).toFixed(0)}%`;
|
|
128
175
|
});
|
|
129
|
-
const canZoomIn = computed(() => {
|
|
176
|
+
const canZoomIn = computed((): boolean => {
|
|
130
177
|
return scaleValue.value > 0.5;
|
|
131
178
|
});
|
|
132
|
-
const canZoomOut = computed(() => {
|
|
179
|
+
const canZoomOut = computed((): boolean => {
|
|
133
180
|
return scaleValue.value < 4;
|
|
134
181
|
});
|
|
135
|
-
function zoomIn
|
|
182
|
+
function zoomIn(): void {
|
|
136
183
|
scaleValue.value = scaleValue.value - 0.1;
|
|
137
184
|
callback();
|
|
138
185
|
}
|
|
139
|
-
function zoomOut
|
|
186
|
+
function zoomOut(): void {
|
|
140
187
|
scaleValue.value = scaleValue.value + 0.1;
|
|
141
188
|
callback();
|
|
142
189
|
}
|
|
@@ -150,58 +197,67 @@ export function useScale (callback) {
|
|
|
150
197
|
};
|
|
151
198
|
}
|
|
152
199
|
|
|
153
|
-
export function useDataSource
|
|
154
|
-
const detailData = ref();
|
|
155
|
-
function getDetail
|
|
200
|
+
export function useDataSource(axios: AxiosInstance) {
|
|
201
|
+
const detailData = ref<any>();
|
|
202
|
+
function getDetail(id: string | number): Promise<any> {
|
|
156
203
|
return axios
|
|
157
204
|
.request({
|
|
158
205
|
url: `/printTemplate/get/${id}`,
|
|
159
206
|
method: 'post',
|
|
160
207
|
})
|
|
161
|
-
.then((res) => {
|
|
208
|
+
.then((res: Response) => {
|
|
162
209
|
if (res.data.data && res.data.data.sourceCodes) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
formCode.value =
|
|
210
|
+
const codes = res.data.data.sourceCodes.split(',');
|
|
211
|
+
const formListCode = dataSourceForm.value.map((item) => item.value);
|
|
212
|
+
const filteredCodes = codes.filter((item) => formListCode.includes(item));
|
|
213
|
+
formCode.value = filteredCodes;
|
|
167
214
|
} else {
|
|
168
|
-
formCode.value =
|
|
215
|
+
formCode.value = [];
|
|
169
216
|
}
|
|
170
217
|
detailData.value = res.data.data;
|
|
171
218
|
return Promise.resolve(res.data.data);
|
|
172
219
|
});
|
|
173
220
|
}
|
|
174
|
-
const listCode = ref([]);
|
|
175
|
-
const dataSourceList = ref([]);
|
|
176
|
-
const listColumns = computed(() => {
|
|
177
|
-
|
|
178
|
-
|
|
221
|
+
const listCode = ref<string[]>([]);
|
|
222
|
+
const dataSourceList = ref<DataSourceOption[]>([]);
|
|
223
|
+
const listColumns = computed((): string[] => {
|
|
224
|
+
if (
|
|
225
|
+
!codeMapDataSource.value[listCode.value[0]] ||
|
|
226
|
+
!Array.isArray(codeMapDataSource.value[listCode.value[0]])
|
|
227
|
+
) {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
return codeMapDataSource.value[listCode.value[0]].map((item) => {
|
|
231
|
+
const index = item.indexOf('[');
|
|
179
232
|
return item.substring(index + 1, item.length - 1);
|
|
180
233
|
});
|
|
181
234
|
});
|
|
182
235
|
|
|
183
|
-
const formCode = ref([]);
|
|
184
|
-
const formColumns = computed(() => {
|
|
185
|
-
|
|
236
|
+
const formCode = ref<string[]>([]);
|
|
237
|
+
const formColumns = computed((): string[] => {
|
|
238
|
+
const arr: string[] = [];
|
|
186
239
|
if (formCode.value && formCode.value.length) {
|
|
187
240
|
formCode.value.forEach((item) => {
|
|
188
|
-
|
|
241
|
+
if (codeMapDataSource.value[item] && Array.isArray(codeMapDataSource.value[item])) {
|
|
242
|
+
arr.push(...codeMapDataSource.value[item]);
|
|
243
|
+
}
|
|
189
244
|
});
|
|
190
245
|
}
|
|
191
246
|
return arr;
|
|
192
247
|
});
|
|
193
|
-
const dataSourceForm = ref([]);
|
|
194
|
-
const codeMapDataSource = ref({});
|
|
195
|
-
function getDataSourceList
|
|
248
|
+
const dataSourceForm = ref<DataSourceOption[]>([]);
|
|
249
|
+
const codeMapDataSource = ref<Record<string, string[]>>({});
|
|
250
|
+
function getDataSourceList(): Promise<void> {
|
|
196
251
|
return axios
|
|
197
252
|
.request({
|
|
198
253
|
url: '/printTemplate/getDsList',
|
|
199
254
|
method: 'post',
|
|
200
255
|
})
|
|
201
|
-
.then((res) => {
|
|
256
|
+
.then((res: Response) => {
|
|
202
257
|
res.data.list.forEach((item) => {
|
|
203
258
|
if (item.columns) {
|
|
204
|
-
codeMapDataSource.value[item.code] =
|
|
259
|
+
codeMapDataSource.value[item.code] =
|
|
260
|
+
item?.columns?.split(',')?.map((col) => `$${item.code}[${col.toUpperCase()}]`) || [];
|
|
205
261
|
}
|
|
206
262
|
if (item.type === 'LIST') {
|
|
207
263
|
dataSourceList.value.push({
|
|
@@ -218,7 +274,7 @@ export function useDataSource (axios) {
|
|
|
218
274
|
});
|
|
219
275
|
}
|
|
220
276
|
|
|
221
|
-
const dataSource = ref([]);
|
|
277
|
+
const dataSource = ref<any[]>([]);
|
|
222
278
|
return {
|
|
223
279
|
detailData,
|
|
224
280
|
getDetail,
|
|
@@ -234,4 +290,10 @@ export function useDataSource (axios) {
|
|
|
234
290
|
};
|
|
235
291
|
}
|
|
236
292
|
|
|
293
|
+
declare global {
|
|
294
|
+
interface Window {
|
|
295
|
+
hiprint: any;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
237
299
|
window.hiprint = hiprint;
|
|
File without changes
|