@v2coding/ui 0.1.6 → 0.1.10

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 (48) hide show
  1. package/dist/v2coding-ui.esm.js +71 -29
  2. package/dist/v2coding-ui.min.js +1 -1
  3. package/dist/v2coding-ui.ssr.js +85 -43
  4. package/package.json +2 -3
  5. package/src/components/dialog/dialog.vue +0 -179
  6. package/src/components/drawer/drawer.vue +0 -523
  7. package/src/components/exports/index.vue +0 -53
  8. package/src/components/exports/remote-exports-dialog.vue +0 -202
  9. package/src/components/field/field.autocomplete.vue +0 -21
  10. package/src/components/field/field.calendar.vue +0 -117
  11. package/src/components/field/field.cascade.vue +0 -233
  12. package/src/components/field/field.checkbox.vue +0 -134
  13. package/src/components/field/field.color.vue +0 -24
  14. package/src/components/field/field.date.vue +0 -145
  15. package/src/components/field/field.fence.vue +0 -856
  16. package/src/components/field/field.icons.vue +0 -123
  17. package/src/components/field/field.lnglat.vue +0 -236
  18. package/src/components/field/field.number.vue +0 -43
  19. package/src/components/field/field.radio.vue +0 -100
  20. package/src/components/field/field.rate.vue +0 -37
  21. package/src/components/field/field.rich.vue +0 -155
  22. package/src/components/field/field.select.vue +0 -210
  23. package/src/components/field/field.slider.vue +0 -66
  24. package/src/components/field/field.switch.vue +0 -14
  25. package/src/components/field/field.text.vue +0 -66
  26. package/src/components/field/field.timepicker.vue +0 -70
  27. package/src/components/field/field.timeselect.vue +0 -24
  28. package/src/components/field/field.trigger.dialog.vue +0 -50
  29. package/src/components/field/field.trigger.popover.vue +0 -63
  30. package/src/components/field/field.upload.file.vue +0 -241
  31. package/src/components/field/field.upload.image.vue +0 -125
  32. package/src/components/fill-view/fill-view.vue +0 -43
  33. package/src/components/form/form.dialog.vue +0 -174
  34. package/src/components/form/form.drawer.vue +0 -246
  35. package/src/components/form/form.fieldset.vue +0 -110
  36. package/src/components/form/form.item.vue +0 -210
  37. package/src/components/form/form.vue +0 -302
  38. package/src/components/history/history.vue +0 -361
  39. package/src/components/icon/icon.vue +0 -63
  40. package/src/components/minimize/minimize.vue +0 -342
  41. package/src/components/page/page.vue +0 -43
  42. package/src/components/page/search-page.vue +0 -202
  43. package/src/components/provider/provider.vue +0 -15
  44. package/src/components/scroll-view/scroll-view.vue +0 -384
  45. package/src/components/table/column.vue +0 -262
  46. package/src/components/table/table.pagination.vue +0 -71
  47. package/src/components/table/table.select.vue +0 -165
  48. package/src/components/table/table.vue +0 -807
@@ -1,302 +0,0 @@
1
- <template>
2
- <el-form v-bind="$attrs" ref="form" :model="model" :label-width="labelWidth" v-on="listeners" @submit.native.prevent="onSubmit">
3
- <component v-for="(field, i) in fields" v-bind="field" v-on="field.listeners" :key="i" :is="field.componentName || 'ui-form-item'"></component>
4
- <slot></slot>
5
- </el-form>
6
- </template>
7
-
8
- <script>
9
- import throttle from 'lodash.throttle';
10
- import Objects from '../../util/objects';
11
- import FormItem from './form.item';
12
- import TableSelectItem from '../table/table.select.item';
13
-
14
- export default {
15
- name: 'ui-form',
16
- inheritAttrs: false,
17
- provide() {
18
- return {
19
- uiForm: this,
20
- };
21
- },
22
- props: {
23
- disabled: Boolean,
24
- labelWidth: {
25
- type: String,
26
- default: '105px',
27
- },
28
- fields: Array,
29
- url: String,
30
- method: {
31
- type: String,
32
- validator: (val) => ['get', 'post', 'put'].includes(val),
33
- default: 'post',
34
- },
35
- /**
36
- * 是否显示 label 后面的冒号
37
- */
38
- colon: {
39
- type: Boolean,
40
- default: undefined,
41
- },
42
- beforeSubmit: {
43
- type: Function,
44
- default: () => void 0,
45
- },
46
- submitting: {
47
- type: Boolean,
48
- default: false,
49
- },
50
- /**
51
- * listeners:
52
- * ready 所有表单项都准备好后触发
53
- * submit 触发提交事件
54
- * after-submit 配置 url 后触发submit事件时触发提交数据完成事件
55
- * validate 任一表单项被校验后触发
56
- **/
57
- },
58
- data() {
59
- this.fieldStatus = []; // [{name,status,componentInstance}, ...]
60
- return {
61
- fieldList: [],// [[name, value], ...]
62
- };
63
- },
64
- computed: {
65
- model() {
66
- return Object.fromEntries(this.fieldList);
67
- },
68
- listeners() {
69
- // eslint-disable-next-line
70
- const {submit, ready, ...listeners} = this.$listeners;
71
- return listeners;
72
- },
73
- },
74
- beforeCreate() {
75
- this.isMounted = false;
76
- },
77
- mounted() {
78
- this.isMounted = true;
79
- this.$el.addEventListener('reset', this.onReset);
80
- this.checkFieldsReady();
81
- },
82
- beforeDestroy() {
83
- this.$el.removeEventListener('reset', this.onReset);
84
- },
85
- methods: {
86
- /**
87
- * @public
88
- */
89
- validate(...args) {
90
- return this.$refs.form.validate(...args);
91
- },
92
- /**
93
- * @public
94
- */
95
- validateField(...args) {
96
- return this.$refs.form.validateField(...args);
97
- },
98
- /**
99
- * @public
100
- */
101
- clearValidate(...args) {
102
- return this.$refs.form.clearValidate(...args);
103
- },
104
- /**
105
- * @public
106
- */
107
- resetValues(values) {
108
- if (!Objects.isObject(values)) {
109
- values = {};
110
- }
111
- const formItems = this.getFormItems();
112
- formItems.forEach(item => {
113
- if (Object.prototype.hasOwnProperty.call(values, item.name)) {
114
- item.resetField(values[item.name]);
115
- } else {
116
- item.resetField();
117
- }
118
- });
119
- },
120
- /**
121
- * @public
122
- */
123
- setValues(values) {
124
- if (!values || !Objects.isObject(values)) {
125
- return;
126
- }
127
- const formItems = this.getFormItems();
128
- Object.entries(values).forEach(([fieldName, fieldValue]) => {
129
- const fieldItem = formItems.find(item => item.name === fieldName);
130
- if (!fieldItem) {
131
- return;
132
- }
133
- fieldItem.fieldValue = fieldValue;
134
- });
135
- },
136
- /**
137
- * @public
138
- */
139
- getValues() {
140
- const formItems = this.getFormItems();
141
- return formItems.reduce((values, item) => {
142
- if (item.ignore === true) {
143
- return values;
144
- }
145
- return {...values, [item.name]: item.fieldValue};
146
- }, {});
147
- },
148
- getFormItems() {
149
- const listSearchItem = (items) => {
150
- return items.reduce((results, item) => {
151
- // TableSelectItem mixins FormItem
152
- if ([FormItem.name, TableSelectItem.name].includes(item.$options.name)) {
153
- results.push(item);
154
- } else {
155
- results.push(...listSearchItem(item.$children || []));
156
- }
157
- return results;
158
- }, []);
159
- };
160
- return listSearchItem(this.$children);
161
- },
162
- /**
163
- * @private
164
- */
165
- addField(name, defaultValue = '', instance) {
166
- if (!Object.hasOwnProperty.call(this.model, name)) {
167
- this.onFieldChange(name, defaultValue, instance);
168
- }
169
- },
170
-
171
- /**
172
- * (函数节流. 600ms内只执行一次, 防止 form 表单多次提交)
173
- * @private
174
- */
175
- onSubmit: throttle(
176
- function() {
177
- let formData = this.getValues();
178
- const allow = this.beforeSubmit(formData);
179
- if (typeof allow === 'boolean' && allow === false) {
180
- return;
181
- }
182
- if (typeof allow === 'object') {
183
- formData = allow;
184
- }
185
- this.validate((valid) => {
186
- if (!valid) {
187
- return;
188
- }
189
- this.$emit('submit', formData);
190
- this.doAction(formData);
191
- });
192
- },
193
- 600,
194
- {trailing: false},
195
- ),
196
- doAction(data) {
197
- if (!this.url) {
198
- return;
199
- }
200
- let def;
201
- this.$emit('update:submitting', true);
202
- if (this.method === 'get') {
203
- def = this.getWithMessage(this.url, {params: data});
204
- } else {
205
- def = this.postWithMessage(this.url, data);
206
- }
207
- def.then((...args) => {
208
- this.$emit('update:submitting', false);
209
- this.$emit('after-submit', ...args);
210
- }).catch((...args) => {
211
- this.$emit('update:submitting', false);
212
- return Promise.reject(...args);
213
- });
214
- },
215
- /**
216
- * @private
217
- */
218
- onReset(e) {
219
- e.preventDefault();
220
- this.resetValues();
221
- this.$emit('reset');
222
- },
223
- /**
224
- * @private
225
- */
226
- trigger(event, ...args) {
227
- if (typeof event !== 'string') {
228
- return;
229
- }
230
- const e = event.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());
231
- if (!this[`onField${e}`]) {
232
- return;
233
- }
234
- this[`onField${e}`](...args);
235
- },
236
- /**
237
- * @private
238
- */
239
- onFieldPending(component) {
240
- if (!component.name) {
241
- return;
242
- }
243
- this.fieldStatus.push({name: component.name, status: false, instance: component});
244
- },
245
- /**
246
- * @private
247
- */
248
- onFieldDestroy(component) {
249
- if (component.name) {
250
- const index = this.fieldStatus.findIndex(item => item.name === component.name);
251
- index !== -1 && this.fieldStatus.splice(index, 1);
252
-
253
- const i = this.fieldList.findIndex(item => item[0] === component.name);
254
- this.fieldList.splice(i, 1);
255
- }
256
- const formItems = this.getFormItems();
257
- if (formItems.length === this.fieldStatus.length) {
258
- this.checkFieldsReady();
259
- }
260
- },
261
- /**
262
- * @private
263
- */
264
- onFieldDone(component) {
265
- if (!component.name) {
266
- return;
267
- }
268
- const index = this.fieldStatus.findIndex(item => item.name === component.name);
269
- index !== -1 && this.fieldStatus.splice(index, 1, {name: component.name, status: true, instance: component});
270
- const formItems = this.getFormItems();
271
- if (formItems.length === this.fieldStatus.length) {
272
- this.checkFieldsReady();
273
- }
274
- },
275
- onFieldChange(fieldName, fieldValue, instance) {
276
- const index = this.fieldList.findIndex(item => item[0] === fieldName);
277
- const current = Object.freeze([fieldName, fieldValue, instance]);
278
- if (index === -1) {
279
- this.fieldList.push(current);
280
- } else {
281
- this.fieldList.splice(index, 1, current);
282
- }
283
- },
284
- checkFieldsReady() {
285
- if (!this.isMounted) {
286
- return;
287
- }
288
- const isPending = this.fieldStatus.some(item => !item.status);
289
- if (!isPending && !this.isReady) {
290
- this.isReady = true;
291
- this.$emit('ready');
292
- }
293
- },
294
- },
295
- };
296
- </script>
297
-
298
- <style scoped>
299
- .el-form--inline ::v-deep .el-form-item {
300
- display: inline-flex;
301
- }
302
- </style>
@@ -1,361 +0,0 @@
1
- <template>
2
- <div class="history" v-show="visible">
3
- <scroll-view ref="menus" class="history-tabs">
4
- <div
5
- v-for="item in items"
6
- :key="item.path"
7
- :class="['history-menu', current === item.path ? 'is-active' : '']"
8
- @click="onTabClick(item.path)"
9
- >
10
- <span class="ellipsis" :title="item.title">{{ item.title }}</span>
11
- <i class="el-icon-close" @click.stop="onTabRemove(item.path)"></i>
12
- </div>
13
- </scroll-view>
14
- <div class="contextmenu" :style="contextmenu">
15
- <div
16
- class="modal"
17
- ref="modal"
18
- :style="{ display: activeContextMenu ? 'block' : 'none' }"
19
- @click="hideContextMenu"
20
- ></div>
21
- <el-dropdown
22
- @command="contextmenuClose"
23
- trigger="click"
24
- ref="context"
25
- placement="top-start"
26
- class="history-dropdown"
27
- >
28
- <span></span>
29
- <el-dropdown-menu
30
- class="history-contextmenu"
31
- slot="dropdown"
32
- :visible-arrow="false"
33
- >
34
- <el-dropdown-item command="left">
35
- <i class="el-icon-arrow-left"></i>
36
- 关闭左侧
37
- </el-dropdown-item>
38
- <el-dropdown-item command="right">
39
- <i class="el-icon-arrow-right"></i>
40
- 关闭右侧
41
- </el-dropdown-item>
42
- <el-dropdown-item command="other">
43
- <i class="el-icon-close"></i>
44
- 关闭其它
45
- </el-dropdown-item>
46
- <el-dropdown-item command="all">
47
- <i class="el-icon-circle-close"></i>
48
- 全部关闭
49
- </el-dropdown-item>
50
- </el-dropdown-menu>
51
- </el-dropdown>
52
- </div>
53
- </div>
54
- </template>
55
-
56
- <script>
57
- import ScrollView from '../scroll-view/scroll-view';
58
-
59
- export default {
60
- name: "ui-history",
61
- components: {ScrollView},
62
- props: {
63
- items: Array,
64
- current: null,
65
- visible: {
66
- type: Boolean,
67
- default: true,
68
- },
69
- },
70
- data() {
71
- return {
72
- activeContextMenu: "",
73
- contextmenu: {
74
- width: "0px",
75
- left: "0px",
76
- },
77
- };
78
- },
79
- watch: {
80
- async current() {
81
- if (!this.$refs.menus) {
82
- return;
83
- }
84
- await this.$nextTick();
85
- await this.$refs.menus.$nextTick();
86
- this.$refs.menus.scrollToActiveItem();
87
- },
88
- },
89
- mounted() {
90
- document.addEventListener("contextmenu", this.onContextMenu);
91
- },
92
- beforeDestroy() {
93
- document.removeEventListener("contextmenu", this.onContextMenu);
94
- },
95
- methods: {
96
- showContextMenu() {
97
- setTimeout(() => {
98
- this.$refs.context.broadcast("ElDropdownMenu", "visible", true);
99
- });
100
- },
101
- hideContextMenu() {
102
- this.$refs.context.broadcast("ElDropdownMenu", "visible", false);
103
- this.activeContextMenu = "";
104
- },
105
- onTabClick(path) {
106
- this.$router.push({ path });
107
- },
108
- onTabRemove(path) {
109
- this.$emit("remove-history", { type: "current", name: path });
110
- },
111
- onContextMenu(event) {
112
- const container = this.$el.querySelector(".ui-scroll-view__nav");
113
- const index = this.getChildContainIndex(container, event.target);
114
- const rect = this.$el.getBoundingClientRect();
115
- if (index !== -1) {
116
- this.activeContextMenu = this.items[index]?.path;
117
- this.contextmenu.left = `${event.clientX - rect.left}px`;
118
- this.contextmenu.top = `${event.clientY - rect.top}px`;
119
- this.showContextMenu();
120
- event.preventDefault();
121
- return false;
122
- }
123
- const modal = this.$el.querySelector(".modal");
124
- if (event.target === modal) {
125
- event.preventDefault();
126
- return false;
127
- }
128
- return true;
129
- },
130
- contextmenuClose(command) {
131
- this.$emit("remove-history", {
132
- type: command,
133
- name: this.activeContextMenu,
134
- });
135
- this.hideContextMenu();
136
- },
137
- getChildContainIndex(container, target) {
138
- return Array.from(container.childNodes).findIndex((child) => {
139
- return this.isContains(child, target);
140
- });
141
- },
142
- isContains(container, target) {
143
- if (container === target) {
144
- return true;
145
- }
146
- const fn = (childNodes, _target) => {
147
- return Array.from(childNodes).find((item) => {
148
- const isEq = item === _target;
149
- if (isEq) {
150
- return true;
151
- }
152
- if (!item.childNodes.length) {
153
- return false;
154
- }
155
- return fn(item.childNodes, _target);
156
- });
157
- };
158
- return fn(container.childNodes, target);
159
- },
160
- },
161
- };
162
- </script>
163
-
164
- <style lang="scss">
165
- .history {
166
- flex: none;
167
- height: 40px;
168
- position: relative;
169
- margin: 10px 0 0;
170
-
171
- .history-tabs.ui-scroll-view__nav-wrap {
172
- left: 0;
173
- right: 0;
174
- top: 0;
175
- bottom: 0;
176
- position: absolute;
177
- align-items: flex-end;
178
-
179
- .ui-scroll-view__nav-scroll {
180
- flex: 1;
181
- }
182
-
183
- .ui-scroll-view__nav-control {
184
- width: 20px;
185
- height: 30px;
186
-
187
- &.is-disabled {
188
- .menu-nav-control {
189
- &::before,
190
- &::after {
191
- background: var(--color-primary-light-3);
192
- }
193
- }
194
- }
195
- }
196
-
197
- .ui-scroll-view__nav {
198
- align-items: flex-end;
199
- }
200
-
201
- .menu-nav-control {
202
- height: 30px;
203
-
204
- &::before,
205
- &::after {
206
- width: 3px;
207
- height: 12px;
208
- background: var(--color-primary-light-6);
209
- }
210
-
211
- &::before {
212
- bottom: -2px;
213
- }
214
-
215
- &::after {
216
- top: -2px;
217
- }
218
- }
219
- }
220
-
221
- .contextmenu {
222
- width: 0;
223
- height: 0;
224
- position: absolute;
225
- top: 0;
226
- left: 0;
227
-
228
- .modal {
229
- position: fixed;
230
- top: 0;
231
- left: 0;
232
- bottom: 0;
233
- right: 0;
234
- z-index: 99;
235
- }
236
- }
237
-
238
- .history-menu {
239
- height: 30px;
240
- color: #fff;
241
- font-size: 14px;
242
- display: flex;
243
- flex-direction: row;
244
- align-items: center;
245
- justify-content: space-between;
246
- cursor: pointer;
247
- background: rgba(83,109,139,.6);
248
- border-radius: 5px 5px 0 0;
249
- transition: all 0.3s ease-in-out;
250
- position: relative;
251
- background: var(--color-primary-light-9);
252
-
253
- & + .history-menu {
254
- border-left: 1px solid var(--color-darken-primary-2);
255
- }
256
-
257
- &.is-active {
258
- height: 40px;
259
- color: #ffffff;
260
- background: var(--color-darken-primary-2);
261
- text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.95);
262
- box-shadow: 7px 5px 5px rgba(0, 0, 0, 0.2);
263
- z-index: 1;
264
- }
265
-
266
- &:hover {
267
- i {
268
- opacity: 1;
269
- }
270
- }
271
-
272
- > span {
273
- flex: 1;
274
- padding: 0 25px;
275
- }
276
-
277
- > i {
278
- position: absolute;
279
- top: 2px;
280
- right: 3px;
281
- opacity: 0.3;
282
- width: 14px;
283
- height: 14px;
284
- font-size: 12px;
285
- border-radius: 50%;
286
- transition: opacity 0.3s ease-in-out;
287
-
288
- &:hover {
289
- background-color: var(--color-primary);
290
- }
291
- }
292
- }
293
-
294
- .el-tabs {
295
- background: transparent;
296
-
297
- > .el-tabs__header {
298
- background: transparent;
299
- border-bottom: none;
300
-
301
- .el-tabs__nav {
302
- border: none;
303
- }
304
-
305
- .el-tabs__nav-wrap::after {
306
- content: unset;
307
- }
308
- }
309
-
310
- > .el-tabs__content {
311
- padding: 0;
312
- }
313
-
314
- .el-tabs__nav-next,
315
- .el-tabs__nav-prev {
316
- color: #536d8b;
317
- width: 20px;
318
- line-height: 39px;
319
- text-align: center;
320
- font-size: 18px;
321
- }
322
-
323
- .el-tabs__nav-prev {
324
- border-right: 1px solid #ddd;
325
- }
326
-
327
- .el-tabs__nav-next {
328
- border-left: 1px solid #ddd;
329
- }
330
-
331
- .el-tabs__item {
332
- margin: 8px;
333
- border: none;
334
- height: 34px;
335
- line-height: 34px;
336
- background: #2e557e;
337
- box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
338
- color: #fff;
339
- display: inline-flex;
340
- flex-direction: row;
341
- align-items: center;
342
- }
343
- }
344
-
345
- .history-tab-title {
346
- width: 6em;
347
- display: inline-block;
348
- vertical-align: middle;
349
- }
350
- }
351
-
352
- .history-dropdown {
353
- position: absolute;
354
- top: 0;
355
- left: 0;
356
- }
357
-
358
- .history-contextmenu.el-popper {
359
- margin-top: 0;
360
- }
361
- </style>
@@ -1,63 +0,0 @@
1
- <template>
2
- <svg :class="['ui-icon', 'ui-icon-' + realName]" aria-hidden="true">
3
- <use :xlink:href="`#icon-${realName}`"/>
4
- </svg>
5
- </template>
6
-
7
- <script>
8
- import Iconfont from '../../config/config.iconfont';
9
-
10
- export default {
11
- name: 'ui-icon',
12
- props: {
13
- name: String,
14
- },
15
- data() {
16
- return {
17
- icons: [],
18
- };
19
- },
20
- computed: {
21
- realName({name, icons}) {
22
- const isIncludes = icons.includes(name);
23
- if (isIncludes) {
24
- return name;
25
- }
26
- return 'unknown';
27
- },
28
- },
29
- mounted() {
30
- this.init();
31
- },
32
- methods: {
33
- async init() {
34
- this.icons = await Iconfont.getIcons();
35
- },
36
- },
37
- };
38
- </script>
39
-
40
- <style lang="less" scoped>
41
- .ui-icon {
42
- width: 1em;
43
- height: 1em;
44
- vertical-align: -0.15em;
45
- fill: currentColor;
46
- overflow: hidden;
47
- display: inline-block;
48
-
49
- &.ui-icon-loading {
50
- animation: rotating 2s linear infinite;
51
- }
52
- }
53
-
54
- @keyframes rotating {
55
- from {
56
- transform: rotate(0deg)
57
- }
58
-
59
- to {
60
- transform: rotate(1turn)
61
- }
62
- }
63
- </style>