@v2coding/ui 0.1.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.
Files changed (49) hide show
  1. package/README.md +6 -0
  2. package/dist/v2coding-ui.esm.js +10840 -0
  3. package/dist/v2coding-ui.min.js +1 -0
  4. package/dist/v2coding-ui.ssr.js +10747 -0
  5. package/package.json +54 -0
  6. package/src/components/dialog/dialog.vue +179 -0
  7. package/src/components/drawer/drawer.vue +523 -0
  8. package/src/components/exports/index.vue +53 -0
  9. package/src/components/exports/remote-exports-dialog.vue +202 -0
  10. package/src/components/field/field.autocomplete.vue +21 -0
  11. package/src/components/field/field.calendar.vue +117 -0
  12. package/src/components/field/field.cascade.vue +233 -0
  13. package/src/components/field/field.checkbox.vue +134 -0
  14. package/src/components/field/field.color.vue +24 -0
  15. package/src/components/field/field.date.vue +145 -0
  16. package/src/components/field/field.icons.vue +123 -0
  17. package/src/components/field/field.number.vue +43 -0
  18. package/src/components/field/field.radio.vue +100 -0
  19. package/src/components/field/field.rate.vue +37 -0
  20. package/src/components/field/field.rich.vue +165 -0
  21. package/src/components/field/field.select.vue +210 -0
  22. package/src/components/field/field.slider.vue +66 -0
  23. package/src/components/field/field.switch.vue +14 -0
  24. package/src/components/field/field.text.vue +66 -0
  25. package/src/components/field/field.timepicker.vue +70 -0
  26. package/src/components/field/field.timeselect.vue +24 -0
  27. package/src/components/field/field.trigger.dialog.vue +50 -0
  28. package/src/components/field/field.trigger.popover.vue +63 -0
  29. package/src/components/field/field.upload.file.vue +241 -0
  30. package/src/components/field/field.upload.image.vue +125 -0
  31. package/src/components/field/field.upload.portrait.vue +304 -0
  32. package/src/components/fill-view/index.vue +43 -0
  33. package/src/components/form/form.dialog.vue +174 -0
  34. package/src/components/form/form.drawer.vue +246 -0
  35. package/src/components/form/form.fieldset.vue +110 -0
  36. package/src/components/form/form.item.vue +213 -0
  37. package/src/components/form/form.vue +293 -0
  38. package/src/components/head-menu/index.vue +188 -0
  39. package/src/components/head-menu/menu-item.vue +84 -0
  40. package/src/components/history/index.vue +360 -0
  41. package/src/components/icon/icon.vue +63 -0
  42. package/src/components/minimize/index.vue +342 -0
  43. package/src/components/page/page.vue +43 -0
  44. package/src/components/provider/provider.vue +15 -0
  45. package/src/components/scroll-view/scroll-view.vue +384 -0
  46. package/src/components/table/column.vue +262 -0
  47. package/src/components/table/table.pagination.vue +71 -0
  48. package/src/components/table/table.select.vue +165 -0
  49. package/src/components/table/table.vue +805 -0
@@ -0,0 +1,241 @@
1
+ <template>
2
+ <div class="ui-file-upload-field">
3
+ <el-upload v-if="!preview" v-show="!limit || !pickerValue || pickerValue.length < limit" action="1" :show-file-list="false" :disabled="disabled" :http-request="upload" class="uploader" :class="{disabled: disabled || uploading}">
4
+ <div class="upload-btn" :class="{disabled: uploading}">浏览...</div>
5
+ </el-upload>
6
+ <div class="files">
7
+ <template v-for="(url, index) in pickerValue">
8
+ <div :key="index" v-if="!!url" class="file">
9
+ <i class="el-icon-document">&nbsp;</i>
10
+ <a :href="url" target="_blank">{{ getFileName(url) }}</a>
11
+ <span v-if="hasDeleteBtn" class="close" @click="remove(url)"><i class="el-icon-close"></i></span>
12
+ </div>
13
+ </template>
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import FieldMixin from './field.mixin';
20
+ import Upload from './field.helper.upload';
21
+
22
+ const getUrlSuffix = (url) => {
23
+ if (!url) {
24
+ return '';
25
+ }
26
+ const index = url.lastIndexOf('.');
27
+ if (index === -1) {
28
+ return '';
29
+ }
30
+ return url.substring(index + 1);
31
+ };
32
+
33
+ export default {
34
+ name: 'ui-field-upload-file',
35
+ mixins: [FieldMixin],
36
+ props: {
37
+ url: {
38
+ type: String,
39
+ default: '/aliyun/oss',
40
+ },
41
+ params: Object,
42
+ filename: {
43
+ type: String,
44
+ default: 'file',
45
+ },
46
+ uploadType: {
47
+ type: String,
48
+ validator: (val) => ['oss', 'default'].includes(val),
49
+ default: 'oss',
50
+ },
51
+ limit: {
52
+ type: Number,
53
+ default: 0,
54
+ },
55
+ deleteBtn: {
56
+ type: Boolean,
57
+ default: true,
58
+ },
59
+ /**
60
+ * eg: beforeUpload(file) { ... }
61
+ *
62
+ * return false will cancel upload
63
+ **/
64
+ beforeUpload: {
65
+ type: Function,
66
+ default: () => () => void 0,
67
+ },
68
+ disabled: {
69
+ type: Boolean,
70
+ default: false,
71
+ },
72
+ preview: {
73
+ type: Boolean,
74
+ default: false,
75
+ },
76
+ needCreateAttachment: {
77
+ type: Boolean,
78
+ default: false,
79
+ },
80
+ createAttachmentUrl: {
81
+ type: String,
82
+ default: '/Sys/SysAttachment/create',
83
+ },
84
+ createAttachmentParams: null,
85
+ createAttachment: {
86
+ type: Function,
87
+ default: function(file, url) {
88
+ const params = {name: file.name, suffix: getUrlSuffix(url), url, ...(this.createAttachmentParams || {})};
89
+ return this.$axios.post(this.createAttachmentUrl, params);
90
+ },
91
+ },
92
+ },
93
+ data() {
94
+ return {
95
+ uploading: false,
96
+ };
97
+ },
98
+ computed: {
99
+ pickerValue() {
100
+ if (!this.value || typeof this.value !== 'string') {
101
+ return [];
102
+ }
103
+ return this.value.split(',');
104
+ },
105
+ hasDeleteBtn() {
106
+ if (this.preview || this.disabled) {
107
+ return false;
108
+ }
109
+ return this.deleteBtn;
110
+ },
111
+ },
112
+ methods: {
113
+ upload(opt) {
114
+ const {file} = opt;
115
+ const allow = this.beforeUpload(file);
116
+ if (allow === false) {
117
+ return;
118
+ }
119
+ if (this.uploading) {
120
+ return;
121
+ }
122
+ this.uploading = true;
123
+ const uploadServer = Upload[this.uploadType] || Upload.default;
124
+ uploadServer(this.url, {filename: file.name}, {file, filename: this.filename}).then((result) => {
125
+ this.uploading = false;
126
+ if (!result.success) {
127
+ this.$message.error(result.message || '上传失败');
128
+ return;
129
+ }
130
+ this.$message.success('上传成功');
131
+ const url = result.content.url;
132
+ this.onChange([...this.pickerValue, url].join(','));
133
+ this.$emit('afterUpload', result);
134
+ if (this.needCreateAttachment && typeof this.createAttachment === 'function') {
135
+ this.createAttachment(file, url).then(result => {
136
+ this.$emit('create-attachment', result);
137
+ }).catch(error => {
138
+ this.$emit('create-attachment', error);
139
+ });
140
+ }
141
+ }).catch(() => {
142
+ this.uploading = false;
143
+ });
144
+ },
145
+ remove(url) {
146
+ console.log(this.pickerValue);
147
+ console.log(url);
148
+ const index = this.pickerValue.indexOf(url);
149
+ console.log(index);
150
+ if (index === -1) {
151
+ return;
152
+ }
153
+ const cloneValue = [...this.pickerValue];
154
+ cloneValue.splice(index, 1);
155
+ this.onChange(cloneValue.join(','));
156
+ this.$emit('deleteUpload', url);
157
+ },
158
+ getFileName(url) {
159
+ const pathname = new URL(url).pathname;
160
+ return pathname.substring(pathname.lastIndexOf('/') + 1);
161
+ },
162
+ },
163
+ };
164
+ </script>
165
+
166
+ <style lang="less" scoped>
167
+ @primary-color: #409eff;
168
+
169
+ .ui-file-upload-field {
170
+ width: 100%;
171
+ .uploader {
172
+ margin-bottom: 5px;
173
+
174
+ &.disabled ::v-deep .el-upload {
175
+ cursor: not-allowed;
176
+ pointer-events: none;
177
+
178
+ .upload-btn {
179
+ color: #888c94;
180
+ background-color: #edeef0;
181
+ }
182
+ }
183
+ }
184
+
185
+ .upload-btn {
186
+ padding: 5px 10px;
187
+ line-height: 1;
188
+ background-color: @primary-color;
189
+ color: #fff;
190
+ font-size: 12px;
191
+ transition: background-color 0.3s;
192
+
193
+ &:hover {
194
+ background-color: darken(@primary-color, 10%);
195
+ }
196
+ }
197
+
198
+ .files {
199
+ .file {
200
+ color: #606266;
201
+ font-size: 14px;
202
+ transition: all 0.3s;
203
+ cursor: pointer;
204
+ line-height: 28px;
205
+ display: flex;
206
+ align-items: center;
207
+
208
+ a {
209
+ flex: 1;
210
+ color: #606266;
211
+ transition: all 0.3s;
212
+ overflow: hidden;
213
+ text-overflow: ellipsis;
214
+ white-space: nowrap;
215
+ }
216
+
217
+ .close {
218
+ color: transparent;
219
+ width: 28px;
220
+ text-align: center;
221
+ visibility: hidden;
222
+ transition: color 0.3s;
223
+ font-weight: bold;
224
+ }
225
+
226
+ &:hover {
227
+ background-color: #f5f7fa;
228
+
229
+ a {
230
+ color: #409eff;
231
+ }
232
+
233
+ .close {
234
+ color: @primary-color;
235
+ visibility: visible;
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
241
+ </style>
@@ -0,0 +1,125 @@
1
+ <template>
2
+ <div class="ui-image-upload-field">
3
+ <div v-for="(url, index) in pickerValue" :key="index" class="item">
4
+ <el-image :src="url" :preview-src-list="previewBtn ? pickerValue : []" style="width: 100%; height: 100%;"/>
5
+ <div v-if="hasDeleteBtn" class="remove" @click="remove(url)">
6
+ <i class="el-icon-close"></i>
7
+ </div>
8
+ </div>
9
+ <el-upload v-if="!preview" action="1" :show-file-list="false" :http-request="upload" class="uploader" :disabled="disabled" :class="{disabled: disabled || uploading}">
10
+ <div v-show="!limit || !pickerValue || pickerValue.length < limit" class="item upload-btn">
11
+ <i class="el-icon-plus"></i>
12
+ <span>上传图片</span>
13
+ </div>
14
+ </el-upload>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import FileUploadField from './field.upload.file';
20
+
21
+ export default {
22
+ name: 'ui-field-upload-image',
23
+ mixins: [FileUploadField],
24
+ props: {
25
+ previewBtn: {
26
+ type: Boolean,
27
+ default: true,
28
+ },
29
+ url: {
30
+ type: String,
31
+ default: '/aliyun/oss',
32
+ },
33
+ uploadType: {
34
+ type: String,
35
+ default: 'oss',
36
+ },
37
+ },
38
+ };
39
+ </script>
40
+
41
+ <style lang="less" scoped>
42
+ .ui-image-upload-field {
43
+ width: 100%;
44
+ display: flex;
45
+ flex-direction: row;
46
+ flex-wrap: wrap;
47
+
48
+ .uploader.disabled ::v-deep .el-upload {
49
+ cursor: not-allowed;
50
+ pointer-events: none;
51
+
52
+ .upload-btn {
53
+ background: #edeef0;
54
+ color: #888c94;
55
+ }
56
+ }
57
+
58
+ .item {
59
+ position: relative;
60
+ display: flex;
61
+ justify-content: center;
62
+ align-items: center;
63
+ overflow: hidden;
64
+ width: 140px;
65
+ height: 140px;
66
+ margin-bottom: 10px;
67
+ margin-right: 10px;
68
+ border: 1px dashed #d0d2d7;
69
+ padding: 8px;
70
+ border-radius: 2px;
71
+ box-sizing: border-box;
72
+
73
+ .remove {
74
+ position: absolute;
75
+ top: 0;
76
+ right: 0;
77
+ width: 24px;
78
+ height: 24px;
79
+ background-color: rgba(0, 0, 0, 0.7);
80
+ border-radius: 0 0 0 22px;
81
+ cursor: pointer;
82
+
83
+ .el-icon-close {
84
+ position: absolute;
85
+ top: 4px;
86
+ right: 4px;
87
+ color: #fff;
88
+ font-size: 14px;
89
+ }
90
+ }
91
+
92
+ &.upload-btn {
93
+ background: #f7f8f9;
94
+ display: flex;
95
+ flex-direction: column;
96
+ align-items: center;
97
+ justify-content: center;
98
+ border: none;
99
+ color: #409eff;
100
+
101
+ & > .el-icon-plus {
102
+ font-size: 1.6em;
103
+ }
104
+
105
+ & > span {
106
+ font-size: 16px;
107
+ line-height: 1.2;
108
+ margin-top: 5px;
109
+ }
110
+ }
111
+ }
112
+
113
+ .item:hover .modal {
114
+ visibility: visible;
115
+ }
116
+
117
+ ::v-deep .preview {
118
+ display: inline-block;
119
+ width: auto;
120
+ max-width: 60%;
121
+ left: 50%;
122
+ transform: translateX(-50%);
123
+ }
124
+ }
125
+ </style>
@@ -0,0 +1,304 @@
1
+ <template>
2
+ <div>
3
+ <div class="ui-image-upload-file">
4
+ <div class="item" v-show="showPhoto">
5
+ <div class="modal">
6
+ <a :href="photoUrl" target="_blank"><i class="el-icon-zoom-in"></i></a>
7
+ <i class="el-icon-delete" @click="remove()"></i>
8
+ </div>
9
+ <div class="image" :style="{'background-image': `url(${imgUrl})`}"></div>
10
+ </div>
11
+ <el-row v-show="!showPhoto">
12
+ <div @click="showDialog" class="item upload-btn">
13
+ <i class="el-icon-fa-camera"></i>
14
+ </div>
15
+ </el-row>
16
+ </div>
17
+ <ui-dialog :title="title" :visible.sync="visible" width="30%" :confirm="onConfirm">
18
+ <el-row v-loading="videoLoading">
19
+ <video id="videos" width="100%"/>
20
+ </el-row>
21
+ <el-row class="close">
22
+ <el-col v-show="false">
23
+ <canvas id="canvas" :width="w + 'px'" :height="h + 'px'"/>
24
+ </el-col>
25
+ <el-col :span="12">
26
+ <img :src="imgUrl" class="show-img" width="100%" alt="">
27
+ </el-col>
28
+ <el-col :span="12" class="buttons">
29
+ <div class="buttons-desc">
30
+ <div class="capture">
31
+ <div
32
+ :class="{'out-circle': true, reduce: isReduce}"
33
+ @click="capture"
34
+ @mousedown="isReduce = true"
35
+ @mouseup="isReduce = false"
36
+ @mouseleave="isReduce = false"
37
+ >
38
+ <i class="el-icon-fa-camera"></i>
39
+ </div>
40
+ </div>
41
+ <el-button @click="updatePortrait">上传照片</el-button>
42
+ </div>
43
+ </el-col>
44
+ </el-row>
45
+ <span slot="footer" class="dialog-footer">
46
+ <el-button>取 消</el-button>
47
+ <el-button type="primary">确 定</el-button>
48
+ </span>
49
+ </ui-dialog>
50
+ </div>
51
+ </template>
52
+ <script>
53
+ import FieldMixin from './field.mixin';
54
+ import Upload from './field.helper.upload';
55
+
56
+ export default {
57
+ name: 'ui-field-upload-portrait',
58
+ mixins: [FieldMixin],
59
+ data() {
60
+ return {
61
+ videoLoading: true, //相机初始化loading
62
+ isReduce: false, //拍照按钮动画
63
+ front: true,//是否打开后摄像头
64
+ showPhoto: false,
65
+ imgUrl: '',
66
+ photoUrl: '',
67
+ w: 320,
68
+ h: 240,
69
+ };
70
+ },
71
+ props: {
72
+ params: {
73
+ type: Object,
74
+ default: () => ({
75
+ rootDirName: 'image',
76
+ fileType: 2,
77
+ }),
78
+ },
79
+ title: {
80
+ type: String,
81
+ default: '请上传照片',
82
+ },
83
+ filename: {
84
+ type: String,
85
+ default: 'file',
86
+ },
87
+ url: {
88
+ type: String,
89
+ default: '/api/oss/upload',
90
+ },
91
+ uploadType: {
92
+ type: String,
93
+ validator: (val) => ['oss', 'default'].includes(val),
94
+ default: 'default',
95
+ },
96
+ visible: {
97
+ type: Boolean,
98
+ default: false,
99
+ },
100
+ },
101
+ methods: {
102
+ remove() {
103
+ this.imgUrl = '';
104
+ this.showPhoto = false;
105
+ },
106
+ showDialog() {
107
+ this.visible = true;
108
+ this.init();
109
+ },
110
+ onConfirm() {
111
+ if (this.photoUrl === '') {
112
+ this.$message.error('请上传图片后点击确定');
113
+ return;
114
+ }
115
+ this.visible = false;
116
+ this.onChange(this.photoUrl);
117
+ this.showPhoto = true;
118
+ },
119
+ //点击拍照
120
+ capture() {
121
+ const videoDom = document.getElementById('videos');
122
+ const canvas = document.getElementById('canvas');
123
+ const ctx = canvas.getContext('2d');
124
+ ctx.drawImage(videoDom, 0, 0, this.w, this.h);
125
+ this.imgUrl = canvas.toDataURL();
126
+ },
127
+ //初始化 打开摄像头
128
+ init() {
129
+ const _this = this;
130
+ const constraints = {video: {width: this.w, height: this.h, facingMode: {exact: this.front ? 'user' : 'environment'}}};
131
+ navigator.mediaDevices.getUserMedia(constraints).then(function(mediaStream) {
132
+ const video = document.querySelector('video');
133
+ video.srcObject = mediaStream;
134
+ _this.videoLoading = false;
135
+ video.onloadedmetadata = function() {
136
+ video.play();
137
+ };
138
+ }).catch(function(err) {
139
+ console.log(err.name + ': ' + err.message);
140
+ }); // 总是在最后检查错误
141
+ },
142
+ //base64转file
143
+ toFile(value, fileName) {
144
+ if (value !== null || ('' && value.indexOf('base'))) {
145
+ const arr = value.split(','), mime = arr[0].match(/:(.*?);/)[1], bsTr = atob(arr[1]);
146
+ let n = bsTr.length, u8arr = new Uint8Array(n);
147
+ while (n--) {
148
+ u8arr[n] = bsTr.charCodeAt(n);
149
+ }
150
+ return new File([u8arr], fileName, {type: mime});
151
+ }
152
+ },
153
+ //上传照片
154
+ updatePortrait() {
155
+ if (!this.imgUrl) {
156
+ this.$message.error('请先拍照后上传');
157
+ return;
158
+ }
159
+ const file = this.toFile(this.imgUrl, 'file.png');
160
+ console.log(file);
161
+ const uploadServer = Upload[this.uploadType] || Upload.default;
162
+ uploadServer(this.url, this.params, {file, filename: this.filename}).then((result) => {
163
+ console.log(result);
164
+ this.photoUrl = result.content.url;
165
+ if (!result.success) {
166
+ this.$message.error(result.message || '上传失败');
167
+ return;
168
+ }
169
+ this.$message.success('上传成功');
170
+ this.onChange('');
171
+ });
172
+ },
173
+ },
174
+ };
175
+ </script>
176
+ <style lang="less" scoped>
177
+ .ui-image-upload-file {
178
+ width: 100%;
179
+ display: flex;
180
+ flex-direction: row;
181
+ flex-wrap: wrap;
182
+
183
+ .item {
184
+ position: relative;
185
+ display: flex;
186
+ justify-content: center;
187
+ align-items: center;
188
+ overflow: hidden;
189
+ width: 140px;
190
+ height: 140px;
191
+ margin-bottom: 10px;
192
+ margin-right: 10px;
193
+ border: 1px dashed #d0d2d7;
194
+ padding: 8px;
195
+ border-radius: 2px;
196
+ box-sizing: border-box;
197
+
198
+ .modal {
199
+ position: absolute;
200
+ top: 0;
201
+ right: 0;
202
+ bottom: 0;
203
+ left: 0;
204
+ display: flex;
205
+ align-items: center;
206
+ justify-content: space-around;
207
+ background: rgba(0, 0, 0, 0.5);
208
+ visibility: hidden;
209
+ line-height: initial;
210
+ border-radius: 2px;
211
+
212
+ [class^='el-icon-'] {
213
+ color: #fff;
214
+ font-size: 1.5em;
215
+ cursor: pointer;
216
+ }
217
+ }
218
+
219
+ > .image {
220
+ width: 100%;
221
+ height: 100%;
222
+ background: no-repeat center;
223
+ background-size: contain;
224
+ }
225
+
226
+ &.upload-btn {
227
+ background: #edeef0;
228
+ display: flex;
229
+ align-items: center;
230
+ justify-content: center;
231
+ border: none;
232
+ cursor: pointer;
233
+
234
+ & > i {
235
+ width: 2em;
236
+ color: #888c94;
237
+ font-size: 20px;
238
+ line-height: 1.2;
239
+ }
240
+ }
241
+ }
242
+
243
+ .item:hover .modal {
244
+ visibility: visible;
245
+ }
246
+
247
+ ::v-deep .preview {
248
+ display: inline-block;
249
+ width: auto;
250
+ max-width: 60%;
251
+ left: 50%;
252
+ transform: translateX(-50%);
253
+ }
254
+ }
255
+
256
+ .show-img {
257
+ border: 1px dashed #ccc;
258
+ padding: 5px;
259
+ }
260
+
261
+ .capture {
262
+ width: 60px;
263
+ height: 60px;
264
+ border-radius: 50%;
265
+ background: #ccc;
266
+ text-align: center;
267
+ color: #CCC;
268
+ overflow: hidden;
269
+ margin: 0 auto 10px;
270
+
271
+ .out-circle {
272
+ width: 50px;
273
+ height: 50px;
274
+ background: #FFF;
275
+ border-radius: 50%;
276
+ line-height: 55px;
277
+ margin: 5px auto;
278
+ overflow: hidden;
279
+ cursor: pointer;
280
+
281
+ i {
282
+ font-size: 20px;
283
+ }
284
+ }
285
+
286
+ .reduce {
287
+ transform: scale(.8);
288
+ transition: .2s linear;
289
+ }
290
+ }
291
+
292
+ .buttons {
293
+ position: relative;
294
+ height: 240px;
295
+
296
+ .buttons-desc {
297
+ position: absolute;
298
+ top: 50%;
299
+ left: 50%;
300
+ transform: translate(-50%, -50%);
301
+
302
+ }
303
+ }
304
+ </style>
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div :class="['ui-fill-view', direction]">
3
+ <div class="wrapper" :style="directionStyle">
4
+ <slot></slot>
5
+ </div>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ export default {
11
+ name: 'ui-fill-view',
12
+ props: {
13
+ direction: {
14
+ validator: (val) => ['column', 'row'].includes(val),
15
+ default: 'column',
16
+ },
17
+ },
18
+ computed: {
19
+ directionStyle() {
20
+ return {
21
+ flexDirection: this.direction,
22
+ };
23
+ },
24
+ },
25
+ };
26
+ </script>
27
+
28
+ <style lang="less" scoped>
29
+ .ui-fill-view {
30
+ flex: 1;
31
+ position: relative;
32
+
33
+ .wrapper {
34
+ position: absolute;
35
+ top: 0;
36
+ bottom: 0;
37
+ left: 0;
38
+ right: 0;
39
+ display: flex;
40
+ flex-direction: column;
41
+ }
42
+ }
43
+ </style>