lshcom 1.0.6 → 1.0.7
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 +1 -1
- package/src/common/global.js +1 -1
- package/src/components/el/Select.vue +34 -15
package/package.json
CHANGED
package/src/common/global.js
CHANGED
|
@@ -38,7 +38,7 @@ const global = {
|
|
|
38
38
|
},
|
|
39
39
|
// 保留
|
|
40
40
|
retain:{
|
|
41
|
-
number(val = '') {
|
|
41
|
+
number(val = '') {return val.replace(/[^\d]/g,'')}, // 只保留数字
|
|
42
42
|
decimals2(val = '') {return val.replace(/[^\d.]/g,'').replace(/\.{2,}/g,'.').replace(/^\./g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')}, // 保留两位小数
|
|
43
43
|
},
|
|
44
44
|
format(date, fmt = 'yyyy-MM-dd hh:mm:ss') {
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
placeholder: { type: String, default: '请选择' }, // 占位符
|
|
37
37
|
multiple: { type: Boolean, default: false }, // 是否多选
|
|
38
38
|
selectAllable: Boolean, // 是否可全选
|
|
39
|
+
selectAllLable: { type: String, default: '全部' }, // 全选的label
|
|
40
|
+
selectAllValue: { type: String, default: '' }, // 全选的value
|
|
39
41
|
collapseTags: { type: Boolean, default: false }, // 多选时是否将选中值按文字的形式展示
|
|
40
42
|
disabled: { type: Boolean, default: false }, // 是否禁用
|
|
41
43
|
clearable: { type: Boolean, default: true }, // 是否可以清空选项
|
|
@@ -67,7 +69,8 @@
|
|
|
67
69
|
this.selectValue = val
|
|
68
70
|
},
|
|
69
71
|
options: function (val, oldVal) {
|
|
70
|
-
this.selectOptions = val
|
|
72
|
+
this.selectOptions = JSON.parse(JSON.stringify(val))
|
|
73
|
+
this.unshiftAll()
|
|
71
74
|
},
|
|
72
75
|
},
|
|
73
76
|
computed: {
|
|
@@ -80,10 +83,7 @@
|
|
|
80
83
|
},
|
|
81
84
|
},
|
|
82
85
|
mounted() {
|
|
83
|
-
this.
|
|
84
|
-
this.selectOptions = this.options
|
|
85
|
-
this.queryParams[this.pageKey[0]] = this.pageStart
|
|
86
|
-
this.queryParams[this.pageKey[1]] = this.pageNums
|
|
86
|
+
this.resetData()
|
|
87
87
|
},
|
|
88
88
|
methods: {
|
|
89
89
|
change(value){
|
|
@@ -94,20 +94,23 @@
|
|
|
94
94
|
this.$refs.select.previousQuery = this.queryParams[this.queryKey]
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
+
// 全选和单选交互
|
|
97
98
|
if(this.multiple && this.selectAllable){
|
|
98
|
-
if(value.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
if(value.length === 1 && value[0] === this.selectAllValue) {
|
|
100
|
+
this.$emit('input', value)
|
|
101
|
+
this.$emit('change', value)
|
|
102
|
+
return
|
|
103
|
+
} else if(value.length === 2 && value[0] === this.selectAllValue) {
|
|
104
|
+
value.splice(0, 1)
|
|
105
|
+
} else if(value.includes(this.selectAllValue)) {
|
|
106
|
+
value = [this.selectAllValue]
|
|
104
107
|
} else {
|
|
105
|
-
this
|
|
108
|
+
this.$emit('change', value)
|
|
106
109
|
}
|
|
107
|
-
|
|
110
|
+
} else {
|
|
111
|
+
this.$emit('change', value)
|
|
108
112
|
}
|
|
109
113
|
this.$emit('input', value)
|
|
110
|
-
this.$emit('change', value)
|
|
111
114
|
},
|
|
112
115
|
removeTag(value){
|
|
113
116
|
this.$emit('remove-tag', value)
|
|
@@ -130,6 +133,15 @@
|
|
|
130
133
|
})
|
|
131
134
|
}
|
|
132
135
|
},
|
|
136
|
+
// 重置数据
|
|
137
|
+
resetData(){
|
|
138
|
+
this.firstGetData = true
|
|
139
|
+
this.selectValue = this.value
|
|
140
|
+
this.selectOptions = JSON.parse(JSON.stringify(this.options))
|
|
141
|
+
this.unshiftAll()
|
|
142
|
+
this.queryParams[this.pageKey[0]] = this.pageStart
|
|
143
|
+
this.queryParams[this.pageKey[1]] = this.pageNums
|
|
144
|
+
},
|
|
133
145
|
loadmore(){
|
|
134
146
|
if (!this.remote) return;
|
|
135
147
|
if (this.nomore) return;
|
|
@@ -149,6 +161,7 @@
|
|
|
149
161
|
},
|
|
150
162
|
// 下拉框出现时,第一次获取数据
|
|
151
163
|
visibleChange(val) {
|
|
164
|
+
this.$emit('visible-change', val)
|
|
152
165
|
if (val && this.api) {
|
|
153
166
|
if (this.firstGetData) this.getData();
|
|
154
167
|
// 远程搜索把搜索值附上
|
|
@@ -163,7 +176,13 @@
|
|
|
163
176
|
})
|
|
164
177
|
}
|
|
165
178
|
}
|
|
166
|
-
}
|
|
179
|
+
},
|
|
180
|
+
// 添加全部选项
|
|
181
|
+
unshiftAll() {
|
|
182
|
+
if(this.multiple && this.selectAllable && (!this.selectOptions[0] || this.selectOptions[0][this.optionValue] != this.selectAllValue)) {
|
|
183
|
+
this.selectOptions.unshift({[this.optionLabel]: this.selectAllLable, [this.optionValue]: this.selectAllValue})
|
|
184
|
+
}
|
|
185
|
+
},
|
|
167
186
|
},
|
|
168
187
|
};
|
|
169
188
|
</script>
|