@jx3box/jx3box-vue3-ui 0.3.2 → 0.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-vue3-ui",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "JX3BOX Vue3 UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,185 @@
1
+ <template>
2
+ <div class="c-upload-album">
3
+ <Upload @insert="updateFileList" text="批量上传图片" />
4
+ <div class="c-upload-album-list">
5
+ <div class="m-album" id="uploadAlbum" v-if="imgList && imgList.length">
6
+ <div class="u-album-item" v-for="(item, i) in imgList" :key="timeStamp + i">
7
+ <img class="u-pic" :src="item.url ? item.url : item" />
8
+ <i class="u-mask"></i>
9
+ <el-icon class="u-op u-preview" @click="previewHandle(item)"><ZoomIn /></el-icon>
10
+ <el-icon class="u-op u-delete" @click="deleteHandle(i)"><Delete /></el-icon>
11
+ </div>
12
+ </div>
13
+ <div class="u-null" v-else><i class="el-icon-warning-outline"></i> 当前没有任何图片</div>
14
+ </div>
15
+ <el-dialog class="c-upload-album-preview" v-model="dialogVisible">
16
+ <img class="u-img" :src="dialogImageUrl" alt />
17
+ </el-dialog>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ const { getThumbnail } = require("@jx3box/jx3box-common/js/utils.js");
23
+ import Upload from "./Upload.vue";
24
+ import Sortable from "sortablejs";
25
+
26
+ export default {
27
+ name: "UploadAlum",
28
+ props: ["data"],
29
+ data: function () {
30
+ return {
31
+ imgList: this.data || [],
32
+ dialogImageUrl: "",
33
+ dialogVisible: false,
34
+ timeStamp: new Date().getTime() + Math.random(),
35
+ };
36
+ },
37
+ model: {
38
+ prop: "data", //向上同步数据
39
+ event: "update",
40
+ },
41
+ watch: {
42
+ data: {
43
+ immediate: true,
44
+ deep: true,
45
+ handler: function (newVal) {
46
+ this.imgList = newVal || [];
47
+ if (this.imgList.length) {
48
+ this.$nextTick(() => {
49
+ this.sort();
50
+ });
51
+ }
52
+ },
53
+ },
54
+ imgList: {
55
+ deep: true,
56
+ handler: function (newVal) {
57
+ this.$nextTick(() => {
58
+ this.sort();
59
+ });
60
+ this.$emit("update", newVal);
61
+ },
62
+ },
63
+ },
64
+ computed: {},
65
+ methods: {
66
+ updateFileList: function (data) {
67
+ let upload_list = data.list;
68
+ let img_list = [];
69
+ upload_list.forEach((item) => {
70
+ if (item.is_img) {
71
+ img_list.push({
72
+ name: item.name,
73
+ url: item.url,
74
+ });
75
+ }
76
+ });
77
+ this.imgList = [...this.imgList, ...img_list];
78
+ },
79
+ previewHandle: function (item) {
80
+ this.dialogImageUrl = item;
81
+ this.dialogVisible = true;
82
+ },
83
+ deleteHandle: function (i) {
84
+ this.imgList.splice(i, 1);
85
+ },
86
+ sort() {
87
+ var el = document.getElementById("uploadAlbum");
88
+ var sortable = Sortable.create(el);
89
+ },
90
+ showThumbnail(val) {
91
+ return getThumbnail(val, 146);
92
+ },
93
+ },
94
+ components: {
95
+ Upload,
96
+ },
97
+ };
98
+ </script>
99
+
100
+ <style lang="less">
101
+ .c-upload-album {
102
+ .flex;
103
+ .w(100%);
104
+ flex-direction: column;
105
+ gap: 20px;
106
+ .c-upload-album-list {
107
+ .flex;
108
+ .w(100%);
109
+ .r(8px);
110
+ gap: 20px;
111
+ box-sizing: border-box;
112
+ flex-wrap: wrap;
113
+ padding: 20px;
114
+ border: 2px dashed #eee;
115
+ @h: 148px;
116
+ min-height: @h;
117
+ .u-null {
118
+ .x;
119
+ .auto(x);
120
+ .fz(12px,@h);
121
+ color: #999;
122
+ }
123
+ .m-album {
124
+ .flex;
125
+ gap:10px;
126
+ .u-album-item {
127
+ .pr;
128
+ .size(@h);
129
+ img {
130
+ .db;
131
+ .size(100%);
132
+ }
133
+ overflow: hidden;
134
+ background-color: #fff;
135
+ border: 1px solid #c0ccda;
136
+ border-radius: 6px;
137
+ box-sizing: border-box;
138
+ display: inline-block;
139
+ &:hover {
140
+ .u-mask,
141
+ .u-op {
142
+ .db;
143
+ }
144
+ }
145
+ }
146
+
147
+ .u-mask,
148
+ .u-op {
149
+ .pa;
150
+ .none;
151
+ }
152
+ .u-op {
153
+ .pointer;
154
+ }
155
+ .u-mask {
156
+ background-color: rgba(0, 0, 0, 0.5);
157
+ transition: opacity 0.3s;
158
+ .lt(0);
159
+ .size(100%);
160
+ .none;
161
+ cursor: move;
162
+ }
163
+ .u-delete,
164
+ .u-preview {
165
+ .fz(20px);
166
+ color: #fff;
167
+ .lt(50%);
168
+ .size(20px);
169
+ transform: translate(-50%, -50%);
170
+ }
171
+ .u-delete {
172
+ .ml(20px);
173
+ }
174
+ .u-preview {
175
+ .ml(-20px);
176
+ }
177
+ }
178
+ }
179
+ }
180
+ .c-upload-album-preview {
181
+ .u-img {
182
+ min-width: 800px;
183
+ }
184
+ }
185
+ </style>