emacroh5lib 1.0.2 → 1.0.3
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 +2 -1
- package/package.json +8 -2
- package/src/index.ts +4 -2
- package/src/router/index.ts +5 -0
- package/src/shims-vue.d.ts +1 -1
- package/src/views/DragResizeView/index.vue +3 -0
- package/src/views/DragResizeView/vue-drag-resize.css +46 -0
- package/src/views/DragResizeView/vue-drag-resize.html +17 -0
- package/src/views/DragResizeView/vue-drag-resize.js +868 -0
- package/src/views/ExcelExporter/index.less +16 -0
- package/src/views/ExcelExporter/index.vue +74 -0
- package/src/views/ImageViewer/index.vue +505 -0
- package/src/views/ImageViewer/style/css/index.css +186 -0
- package/src/views/ImageViewer/style/css/index.less +212 -0
- package/src/views/ImageViewer/style/images/icons.png +0 -0
- package/src/views/TestView/Export2Excel.ts +496 -0
- package/src/views/TestView/index.less +25 -0
- package/src/views/TestView/index.vue +231 -0
- package/src/views/TestView/list.json +12007 -0
- package/tsconfig.json +1 -1
- package/webpack.config.js +7 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="app-container">
|
3
|
+
|
4
|
+
<button @click="handleOpen">打开查看器</button>
|
5
|
+
<button @click="exportExcel($event)">透过Excel模板导出表格</button>
|
6
|
+
|
7
|
+
<image-viewer :list="srcList" @open="openCallback" @close="closeCallback" :show.sync="showViewer"
|
8
|
+
:currentIndex="currentIndex" />
|
9
|
+
|
10
|
+
|
11
|
+
<div class="list" id="list">
|
12
|
+
|
13
|
+
<DragResizeView v-for="(rect, index) in rects" :key="index" :isStorage="true" :name="rect.name" :w="rect.width" :h="rect.height"
|
14
|
+
:x="rect.left" :y="rect.top" :parentW="listWidth" :parentH="listHeight" :axis="rect.axis"
|
15
|
+
:isActive="rect.active" :minw="rect.minw" :minh="rect.minh" :isDraggable="rect.draggable"
|
16
|
+
:isResizable="rect.resizable" :parentLimitation="rect.parentLim" :snapToGrid="rect.snapToGrid"
|
17
|
+
:aspectRatio="rect.aspectRatio" :z="rect.zIndex" :contentClass="rect.class" v-on:activated="activateEv(index)"
|
18
|
+
v-on:deactivated="deactivateEv(index)" v-on:dragging="changePosition($event, index)"
|
19
|
+
v-on:resizing="changeSize($event, index)">
|
20
|
+
<div class="filler" :style="{ backgroundColor: rect.color }"></div>
|
21
|
+
</DragResizeView>
|
22
|
+
|
23
|
+
</div>
|
24
|
+
|
25
|
+
|
26
|
+
</div>
|
27
|
+
</template>
|
28
|
+
|
29
|
+
<script lang="ts">
|
30
|
+
import { Component, Vue } from "vue-property-decorator";
|
31
|
+
import ImageViewer from "@/views/ImageViewer/index.vue";
|
32
|
+
import DragResizeView from "@/views/DragResizeView/index.vue";
|
33
|
+
|
34
|
+
import { formatJson, export_json_to_excel, number_to_excel, testToExcel } from "./Export2Excel"
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
import LAY_EXCEL from 'lay-excel';
|
39
|
+
|
40
|
+
@Component({
|
41
|
+
components: {
|
42
|
+
ImageViewer,
|
43
|
+
DragResizeView
|
44
|
+
},
|
45
|
+
mounted() {
|
46
|
+
|
47
|
+
}
|
48
|
+
})
|
49
|
+
export default class TestView extends Vue {
|
50
|
+
|
51
|
+
public currentIndex: Number = 0; // 打开图片查看器时,需要定位到的图片的索引
|
52
|
+
public srcList: Array<String> = [
|
53
|
+
"https://scpic.chinaz.net/files/pic/pic9/202203/apic39703.jpg",
|
54
|
+
"https://scpic.chinaz.net/files/pic/pic9/202005/zzpic24899.jpg",
|
55
|
+
"https://scpic.chinaz.net/files/pic/pic9/202109/bpic24244.jpg",
|
56
|
+
"https://scpic.chinaz.net/files/pic/pic9/202110/hpic4529.jpg",
|
57
|
+
"https://scpic.chinaz.net/files/pic/pic9/201912/zzpic22106.jpg",
|
58
|
+
"https://scpic.chinaz.net/files/pic/pic9/202202/apic38580.jpg",
|
59
|
+
] // 图片查看器数据集
|
60
|
+
public showViewer: Boolean = false // 是否打开图片查看器
|
61
|
+
|
62
|
+
public listWidth = 0;
|
63
|
+
public listHeight = 0;
|
64
|
+
|
65
|
+
public handleOpen() {
|
66
|
+
this.showViewer = true;
|
67
|
+
}
|
68
|
+
public openCallback() { } // 打开时的回调
|
69
|
+
public closeCallback() { } // 关闭时的回调
|
70
|
+
|
71
|
+
public rects = [
|
72
|
+
{
|
73
|
+
'name': "test-0",
|
74
|
+
'width': 200,
|
75
|
+
'height': 150,
|
76
|
+
'top': 10,
|
77
|
+
'left': 10,
|
78
|
+
'draggable': true,
|
79
|
+
'resizable': true,
|
80
|
+
'minw': 10,
|
81
|
+
'minh': 10,
|
82
|
+
'axis': 'both',
|
83
|
+
'parentLim': true,
|
84
|
+
'snapToGrid': false,
|
85
|
+
'aspectRatio': false,
|
86
|
+
'zIndex': 1,
|
87
|
+
'color': '#EF9A9A',
|
88
|
+
'active': false
|
89
|
+
},
|
90
|
+
{
|
91
|
+
'name': "test-1",
|
92
|
+
'width': 200,
|
93
|
+
'height': 150,
|
94
|
+
'top': 170,
|
95
|
+
'left': 220,
|
96
|
+
'draggable': true,
|
97
|
+
'resizable': true,
|
98
|
+
'minw': 10,
|
99
|
+
'minh': 10,
|
100
|
+
'axis': 'both',
|
101
|
+
'parentLim': true,
|
102
|
+
'snapToGrid': false,
|
103
|
+
'aspectRatio': false,
|
104
|
+
'zIndex': 1,
|
105
|
+
'color': '#E6C27A',
|
106
|
+
'active': false,
|
107
|
+
'class': 'box-shaddow'
|
108
|
+
},
|
109
|
+
{
|
110
|
+
'name': "test-2",
|
111
|
+
'width': 200,
|
112
|
+
'height': 150,
|
113
|
+
'top': 10,
|
114
|
+
'left': 220,
|
115
|
+
'draggable': true,
|
116
|
+
'resizable': true,
|
117
|
+
'minw': 10,
|
118
|
+
'minh': 10,
|
119
|
+
'axis': 'both',
|
120
|
+
'parentLim': true,
|
121
|
+
'snapToGrid': false,
|
122
|
+
'aspectRatio': false,
|
123
|
+
'zIndex': 2,
|
124
|
+
'color': '#AED581',
|
125
|
+
'active': false
|
126
|
+
},
|
127
|
+
{
|
128
|
+
'name': "test-3",
|
129
|
+
'width': 200,
|
130
|
+
'height': 150,
|
131
|
+
'top': 170,
|
132
|
+
'left': 10,
|
133
|
+
'draggable': true,
|
134
|
+
'resizable': true,
|
135
|
+
'minw': 10,
|
136
|
+
'minh': 10,
|
137
|
+
'axis': 'both',
|
138
|
+
'parentLim': true,
|
139
|
+
'snapToGrid': false,
|
140
|
+
'aspectRatio': false,
|
141
|
+
'zIndex': 3,
|
142
|
+
'color': '#81D4FA',
|
143
|
+
'active': false
|
144
|
+
}
|
145
|
+
]
|
146
|
+
|
147
|
+
public exportExcel(e): void {
|
148
|
+
console.log('event', e);
|
149
|
+
|
150
|
+
// testToExcel(e)
|
151
|
+
// LAY_EXCEL.exportExcel([[1, 2, 3]], '表格导出.xlsx', 'xlsx')
|
152
|
+
|
153
|
+
|
154
|
+
// var list = [[null,1, 2, 3], [null,1, 2, "a撒地方打赏打发士大夫"]]
|
155
|
+
var list = {
|
156
|
+
"aaa1撒旦飞洒": [
|
157
|
+
[null, 1, 2, 3]
|
158
|
+
],
|
159
|
+
"bbb1": [
|
160
|
+
[2, 1, 2, null]
|
161
|
+
]
|
162
|
+
}
|
163
|
+
|
164
|
+
// 2. 使用批量设置样式函数 setExportCellStyle 对单元格维度的数据进行批量设置样式
|
165
|
+
// PS:注意这里是ARGB,前两位是透明度
|
166
|
+
LAY_EXCEL.setExportCellStyle(list, 'A1:Z1', {
|
167
|
+
s: {
|
168
|
+
border: {
|
169
|
+
top: { style: 'thick', color: { rgb: 'FFFF0000' } },
|
170
|
+
bottom: { style: 'thick', color: { rgb: 'FFFF0000' } },
|
171
|
+
left: { style: 'thick', color: { rgb: 'FFFF0000' } },
|
172
|
+
right: { style: 'thick', color: { rgb: 'FFFF0000' } }
|
173
|
+
},
|
174
|
+
fill: {
|
175
|
+
fgColor: {
|
176
|
+
rgb: "ffff00"
|
177
|
+
}
|
178
|
+
},
|
179
|
+
font: {
|
180
|
+
name: "楷体",
|
181
|
+
sz: 22,
|
182
|
+
color: {
|
183
|
+
rgb: "ff0000"
|
184
|
+
},
|
185
|
+
bold: true,
|
186
|
+
italic: false,
|
187
|
+
underline: false
|
188
|
+
},
|
189
|
+
}
|
190
|
+
})
|
191
|
+
|
192
|
+
|
193
|
+
LAY_EXCEL.exportExcel(list, '表格导出.xlsx', 'xlsx')
|
194
|
+
}
|
195
|
+
|
196
|
+
activateEv(index) {
|
197
|
+
console.log("activateEv index", index);
|
198
|
+
}
|
199
|
+
|
200
|
+
deactivateEv(index) {
|
201
|
+
console.log("deactivateEv index", index);
|
202
|
+
}
|
203
|
+
|
204
|
+
changePosition(newRect, index) {
|
205
|
+
console.log("changePosition newRect", newRect);
|
206
|
+
console.log("changePosition index", index);
|
207
|
+
}
|
208
|
+
|
209
|
+
changeSize(newRect, index) {
|
210
|
+
console.log("changeSize newRect", newRect);
|
211
|
+
console.log("changeSize index", index);
|
212
|
+
}
|
213
|
+
|
214
|
+
public mounted() {
|
215
|
+
const listEl = document.getElementById('list') as HTMLElement;
|
216
|
+
this.listWidth = listEl.clientWidth;
|
217
|
+
this.listHeight = listEl.clientHeight;
|
218
|
+
|
219
|
+
window.addEventListener('resize', () => {
|
220
|
+
// this.listWidth = listEl.clientWidth;
|
221
|
+
// this.listHeight = listEl.clientHeight;
|
222
|
+
})
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
}
|
227
|
+
</script>
|
228
|
+
|
229
|
+
<style lang="less" scoped>
|
230
|
+
@import "index.less";
|
231
|
+
</style>
|