@lx-frontend/wrap-element-ui 1.0.1-beta.4 → 1.0.1-beta.6

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.
@@ -1,153 +1,153 @@
1
- <template>
2
- <div
3
- class="search-select"
4
- @keyup.up.prevent="navigateOptions($event, 'prev')"
5
- @keyup.down.prevent="navigateOptions($event, 'next')"
6
- @keyup.enter.prevent="selectOption"
7
- >
8
- <el-input
9
- ref="input"
10
- v-model="content"
11
- class="search-select__input"
12
- :placeholder="placeholder"
13
- @input="handleInputChange"
14
- @focus="handleFocus"
15
- @blur="handleBlur"
16
- />
17
- <div
18
- v-if="visible && value !== ''"
19
- class="select-down"
20
- >
21
- <div
22
- v-for="(item, index) in list"
23
- :key="getKey(item, index)"
24
- :class="['select-down__item', {'select-down__item--active': currentId === index}]"
25
- @mouseover="currentId = index"
26
- @click="handleSelect(item)"
27
- >
28
- <div
29
- v-for="(showItem, index) in showList"
30
- :key="getKey(showItem, index)"
31
- :style="`flex: ${showItem.flex}`"
32
- :class="`select-down__box select-down__${showItem.name}`"
33
- >
34
- <span>{{ item[showItem.name] || '--' }}</span>
35
- </div>
36
- </div>
37
- </div>
38
- </div>
39
- </template>
40
-
41
- <script>
42
- export default {
43
- name: 'SearchSelect',
44
- props: {
45
- value: {
46
- default: '',
47
- type: String,
48
- },
49
- placeholder: {
50
- default: '请输入',
51
- type: String,
52
- },
53
- list: {
54
- default: () => [],
55
- type: Array,
56
- },
57
- showList: {
58
- default: () => [],
59
- type: Array,
60
- }
61
- },
62
- data() {
63
- return {
64
- content: '',
65
- visible: false,
66
- currentId: 0
67
- }
68
- },
69
- watch: {
70
- value(val) {
71
- this.content = val
72
- }
73
- },
74
- methods: {
75
- handleFocus() {
76
- this.visible = true
77
- this.$emit('input', this.content)
78
- },
79
- handleInputChange(params) {
80
- this.$emit('update:value', params)
81
- this.$emit('input', params)
82
- },
83
- navigateOptions(e, params) {
84
- e.target.selectionStart = this.content.length
85
- if (params === 'next') this.currentId = this.currentId === this.list.length - 1 ? 0 : this.currentId + 1
86
- if (params === 'prev') this.currentId = this.currentId === 0 ? this.list.length - 1 : this.currentId - 1
87
- },
88
- selectOption() {
89
- this.visible = false
90
- this.$refs.input.blur()
91
- this.$emit('select', this.list[this.currentId])
92
- },
93
- handleBlur() {
94
- const timer = setTimeout(() => {
95
- this.visible = false
96
- clearTimeout(timer)
97
- }, 300)
98
- },
99
- handleSelect(item) {
100
- this.$emit('select', item)
101
- },
102
- getKey (item, index) {
103
- return btoa(escape(`${item}_${index}`))
104
- }
105
- },
106
- };
107
- </script>
108
-
109
- <style lang="less">
110
- .search-select{
111
- position: relative;
112
- width: 100%;
113
-
114
- &__input{
115
- width: 100%;
116
- }
117
- }
118
-
119
- .select-down{
120
- width: 100%;
121
- position: absolute;
122
- z-index: 100;
123
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
124
- border-radius: 4px;
125
- border: 0 solid #d0d0d1;
126
- background-color: #fff;
127
- overflow: hidden;
128
- margin-top: 10px;
129
-
130
- &__item{
131
- height: 30px;
132
- line-height: 30px;
133
- display: flex;
134
- justify-content: space-between;
135
- text-align: center;
136
- box-sizing: border-box;
137
- padding: 0 15px;
138
-
139
- &--active{
140
- background-color: #eee;
141
- }
142
- }
143
-
144
- &__box{
145
- text-align: center;
146
- overflow: hidden;
147
-
148
- &:first-of-type{
149
- text-align: left;
150
- }
151
- }
152
- }
153
- </style>
1
+ <template>
2
+ <div
3
+ class="search-select"
4
+ @keyup.up.prevent="navigateOptions($event, 'prev')"
5
+ @keyup.down.prevent="navigateOptions($event, 'next')"
6
+ @keyup.enter.prevent="selectOption"
7
+ >
8
+ <el-input
9
+ ref="input"
10
+ v-model="content"
11
+ class="search-select__input"
12
+ :placeholder="placeholder"
13
+ @input="handleInputChange"
14
+ @focus="handleFocus"
15
+ @blur="handleBlur"
16
+ />
17
+ <div
18
+ v-if="visible && value !== ''"
19
+ class="select-down"
20
+ >
21
+ <div
22
+ v-for="(item, index) in list"
23
+ :key="getKey(item, index)"
24
+ :class="['select-down__item', {'select-down__item--active': currentId === index}]"
25
+ @mouseover="currentId = index"
26
+ @click="handleSelect(item)"
27
+ >
28
+ <div
29
+ v-for="(showItem, index) in showList"
30
+ :key="getKey(showItem, index)"
31
+ :style="`flex: ${showItem.flex}`"
32
+ :class="`select-down__box select-down__${showItem.name}`"
33
+ >
34
+ <span>{{ item[showItem.name] || '--' }}</span>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </template>
40
+
41
+ <script>
42
+ export default {
43
+ name: 'SearchSelect',
44
+ props: {
45
+ value: {
46
+ default: '',
47
+ type: String,
48
+ },
49
+ placeholder: {
50
+ default: '请输入',
51
+ type: String,
52
+ },
53
+ list: {
54
+ default: () => [],
55
+ type: Array,
56
+ },
57
+ showList: {
58
+ default: () => [],
59
+ type: Array,
60
+ }
61
+ },
62
+ data() {
63
+ return {
64
+ content: '',
65
+ visible: false,
66
+ currentId: 0
67
+ }
68
+ },
69
+ watch: {
70
+ value(val) {
71
+ this.content = val
72
+ }
73
+ },
74
+ methods: {
75
+ handleFocus() {
76
+ this.visible = true
77
+ this.$emit('input', this.content)
78
+ },
79
+ handleInputChange(params) {
80
+ this.$emit('update:value', params)
81
+ this.$emit('input', params)
82
+ },
83
+ navigateOptions(e, params) {
84
+ e.target.selectionStart = this.content.length
85
+ if (params === 'next') this.currentId = this.currentId === this.list.length - 1 ? 0 : this.currentId + 1
86
+ if (params === 'prev') this.currentId = this.currentId === 0 ? this.list.length - 1 : this.currentId - 1
87
+ },
88
+ selectOption() {
89
+ this.visible = false
90
+ this.$refs.input.blur()
91
+ this.$emit('select', this.list[this.currentId])
92
+ },
93
+ handleBlur() {
94
+ const timer = setTimeout(() => {
95
+ this.visible = false
96
+ clearTimeout(timer)
97
+ }, 300)
98
+ },
99
+ handleSelect(item) {
100
+ this.$emit('select', item)
101
+ },
102
+ getKey (item, index) {
103
+ return btoa(escape(`${item}_${index}`))
104
+ }
105
+ },
106
+ };
107
+ </script>
108
+
109
+ <style lang="less">
110
+ .search-select{
111
+ position: relative;
112
+ width: 100%;
113
+
114
+ &__input{
115
+ width: 100%;
116
+ }
117
+ }
118
+
119
+ .select-down{
120
+ width: 100%;
121
+ position: absolute;
122
+ z-index: 100;
123
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
124
+ border-radius: 4px;
125
+ border: 0 solid #d0d0d1;
126
+ background-color: #fff;
127
+ overflow: hidden;
128
+ margin-top: 10px;
129
+
130
+ &__item{
131
+ height: 30px;
132
+ line-height: 30px;
133
+ display: flex;
134
+ justify-content: space-between;
135
+ text-align: center;
136
+ box-sizing: border-box;
137
+ padding: 0 15px;
138
+
139
+ &--active{
140
+ background-color: #eee;
141
+ }
142
+ }
143
+
144
+ &__box{
145
+ text-align: center;
146
+ overflow: hidden;
147
+
148
+ &:first-of-type{
149
+ text-align: left;
150
+ }
151
+ }
152
+ }
153
+ </style>
@@ -1,24 +1,24 @@
1
-
2
- import DemoComponent from './DemoComponent/index.vue'
3
- import AuditSteps from './AuditSteps/index.vue'
4
- import Ellipsis from './Ellipsis/index.vue'
5
- import SearchForm from './SearchForm/index.vue'
6
- import LxTable from './LxTable/index.vue'
7
- import SearchSelect from './SearchSelect/index.vue'
8
- import AddMembers from './AddMembers/index.vue'
9
- import PopoverForm from './PopoverForm/index.vue'
10
- import EditableTable from './EditableTable/index.vue'
11
- import SingleMessage from './singleMessage/index'
12
-
13
- export {
14
- DemoComponent,
15
- AuditSteps,
16
- Ellipsis,
17
- SearchForm,
18
- LxTable,
19
- SearchSelect,
20
- AddMembers,
21
- PopoverForm,
22
- EditableTable,
23
- SingleMessage
24
- }
1
+
2
+ import DemoComponent from './DemoComponent/index.vue'
3
+ import AuditSteps from './AuditSteps/index.vue'
4
+ import Ellipsis from './Ellipsis/index.vue'
5
+ import SearchForm from './SearchForm/index.vue'
6
+ import LxTable from './LxTable/index.vue'
7
+ import SearchSelect from './SearchSelect/index.vue'
8
+ import AddMembers from './AddMembers/index.vue'
9
+ import PopoverForm from './PopoverForm/index.vue'
10
+ import EditableTable from './EditableTable/index.vue'
11
+ import SingleMessage from './singleMessage/index'
12
+
13
+ export {
14
+ DemoComponent,
15
+ AuditSteps,
16
+ Ellipsis,
17
+ SearchForm,
18
+ LxTable,
19
+ SearchSelect,
20
+ AddMembers,
21
+ PopoverForm,
22
+ EditableTable,
23
+ SingleMessage
24
+ }
@@ -1,44 +1,44 @@
1
- import { Message } from 'element-ui';
2
- import MessageType from 'element-ui/packages/message';
3
-
4
-
5
- let messageInstance: MessageType = null;
6
-
7
- const closeMsg = (message: MessageType) => {
8
- message.singleTimer = setTimeout(() => {
9
- message.singleTimer && clearTimeout(message.singleTimer);
10
- message.close();
11
- messageInstance = null;
12
- }, 3000);
13
- };
14
-
15
- const singleMessage: MessageType = (options: any) => {
16
- if (
17
- messageInstance
18
- && (messageInstance.message !== options.message || messageInstance.type !== options.type)
19
- ) {
20
- messageInstance.close();
21
- messageInstance = Message({ ...options, duration: 0 });
22
- return closeMsg(messageInstance);
23
- }
24
- if (messageInstance) {
25
- messageInstance.singleTimer && clearTimeout(messageInstance.singleTimer);
26
- return closeMsg(messageInstance);
27
- }
28
- messageInstance = Message({ ...options, duration: 0 });
29
- closeMsg(messageInstance);
30
- };
31
-
32
- ['error', 'success', 'info', 'warning'].forEach(type => {
33
- singleMessage[type] = options => {
34
- if (typeof options === 'string') {
35
- options = {
36
- message: options,
37
- };
38
- }
39
- options.type = type;
40
- return singleMessage(options);
41
- };
42
- });
43
-
44
- export default singleMessage;
1
+ import { Message } from 'element-ui';
2
+ import MessageType from 'element-ui/packages/message';
3
+
4
+
5
+ let messageInstance: MessageType = null;
6
+
7
+ const closeMsg = (message: MessageType) => {
8
+ message.singleTimer = setTimeout(() => {
9
+ message.singleTimer && clearTimeout(message.singleTimer);
10
+ message.close();
11
+ messageInstance = null;
12
+ }, 3000);
13
+ };
14
+
15
+ const singleMessage: MessageType = (options: any) => {
16
+ if (
17
+ messageInstance
18
+ && (messageInstance.message !== options.message || messageInstance.type !== options.type)
19
+ ) {
20
+ messageInstance.close();
21
+ messageInstance = Message({ ...options, duration: 0 });
22
+ return closeMsg(messageInstance);
23
+ }
24
+ if (messageInstance) {
25
+ messageInstance.singleTimer && clearTimeout(messageInstance.singleTimer);
26
+ return closeMsg(messageInstance);
27
+ }
28
+ messageInstance = Message({ ...options, duration: 0 });
29
+ closeMsg(messageInstance);
30
+ };
31
+
32
+ ['error', 'success', 'info', 'warning'].forEach(type => {
33
+ singleMessage[type] = options => {
34
+ if (typeof options === 'string') {
35
+ options = {
36
+ message: options,
37
+ };
38
+ }
39
+ options.type = type;
40
+ return singleMessage(options);
41
+ };
42
+ });
43
+
44
+ export default singleMessage;