@mptw/skylens-ui 1.2.9 → 1.2.11
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.
|
@@ -123,7 +123,7 @@ import {
|
|
|
123
123
|
previousDateRange,
|
|
124
124
|
isValidDate,
|
|
125
125
|
} from "~ui/utils";
|
|
126
|
-
import {
|
|
126
|
+
import { CABLE_DEFAULT_END_DATE_BEFORE_NOW, MOBILE_DEFAULT_END_DATE_BEFORE_NOW } from "~ui/utils/constants";
|
|
127
127
|
import type IDateRange from "~ui/interface/IDateRange";
|
|
128
128
|
import { OnlineSourceType } from "~ui/interface/IWeb";
|
|
129
129
|
|
|
@@ -289,12 +289,12 @@ export default defineComponent({
|
|
|
289
289
|
switch (dataSourceType.value) {
|
|
290
290
|
case OnlineSourceType.Mobile:
|
|
291
291
|
return formatDate(
|
|
292
|
-
subDays(new Date(),
|
|
292
|
+
subDays(new Date(), MOBILE_DEFAULT_END_DATE_BEFORE_NOW),
|
|
293
293
|
"yyyy/MM/dd"
|
|
294
294
|
);
|
|
295
295
|
default:
|
|
296
296
|
return formatDate(
|
|
297
|
-
subDays(new Date(),
|
|
297
|
+
subDays(new Date(), CABLE_DEFAULT_END_DATE_BEFORE_NOW),
|
|
298
298
|
"yyyy/MM/dd"
|
|
299
299
|
);
|
|
300
300
|
}
|
|
@@ -111,36 +111,53 @@ export default defineComponent({
|
|
|
111
111
|
>,
|
|
112
112
|
default: () => [],
|
|
113
113
|
},
|
|
114
|
+
query: {
|
|
115
|
+
type: String,
|
|
116
|
+
default: '',
|
|
117
|
+
}
|
|
114
118
|
},
|
|
115
|
-
emits: ["update:modelValue", "update:selecting"],
|
|
119
|
+
emits: ["update:modelValue", "update:selecting", 'update:query'],
|
|
116
120
|
setup(props, { emit }) {
|
|
117
|
-
const { size, modelValue, options, placement } = toRefs(props);
|
|
121
|
+
const { size, modelValue, options, placement, query } = toRefs(props);
|
|
118
122
|
|
|
119
123
|
const selectEl = shallowRef<HTMLElement | null>(null);
|
|
120
124
|
const toggleEl = shallowRef<HTMLElement | null>(null);
|
|
121
125
|
const popupEl = shallowRef<HTMLElement | null>(null);
|
|
122
|
-
const
|
|
126
|
+
const selfQuery = ref("");
|
|
123
127
|
const selectedFirstOption = ref<string | null>(null);
|
|
124
128
|
const isSelecting = ref(false);
|
|
125
129
|
|
|
126
130
|
let popperInstance: any = null;
|
|
127
131
|
let clickSubscriber: any = null;
|
|
128
132
|
|
|
133
|
+
const queryProxy = computed({
|
|
134
|
+
get() { query.value || selfQuery },
|
|
135
|
+
set(newValue: string) {
|
|
136
|
+
emit('update:query', newValue);
|
|
137
|
+
selfQuery.value = newValue;
|
|
138
|
+
},
|
|
139
|
+
});
|
|
129
140
|
const sizeClass = computed(() => {
|
|
130
141
|
if (size.value === "") return "";
|
|
131
142
|
return `two-layer-multi-select-${size.value}`;
|
|
132
143
|
});
|
|
133
144
|
const filteredOptions = computed(() => {
|
|
134
|
-
if (
|
|
145
|
+
if (queryProxy.value === "") {
|
|
135
146
|
return options.value;
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
const regexp = new RegExp(`.*${query.value}.*`, "i");
|
|
139
150
|
return options.value
|
|
140
|
-
.map((option) =>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
.map((option) => {
|
|
152
|
+
if (regexp.test(option.name)) {
|
|
153
|
+
return option;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
...option,
|
|
158
|
+
subOptions: option.subOptions.filter((o) => regexp.test(o.name)),
|
|
159
|
+
};
|
|
160
|
+
})
|
|
144
161
|
.filter((option) => option.subOptions.length > 0);
|
|
145
162
|
});
|
|
146
163
|
const firstOptions = computed(() => {
|
|
@@ -309,7 +326,7 @@ export default defineComponent({
|
|
|
309
326
|
selectEl,
|
|
310
327
|
toggleEl,
|
|
311
328
|
popupEl,
|
|
312
|
-
|
|
329
|
+
queryProxy,
|
|
313
330
|
sizeClass,
|
|
314
331
|
selectedFirstOption,
|
|
315
332
|
firstOptions,
|
package/package.json
CHANGED
package/utils/constants.ts
CHANGED
|
@@ -59,7 +59,8 @@ export const POI_CHART_COLORS = [
|
|
|
59
59
|
"#b65f5f"
|
|
60
60
|
];
|
|
61
61
|
|
|
62
|
-
export const
|
|
62
|
+
export const CABLE_DEFAULT_END_DATE_BEFORE_NOW = 6;
|
|
63
|
+
export const MOBILE_DEFAULT_END_DATE_BEFORE_NOW = 3;
|
|
63
64
|
|
|
64
65
|
export const TAIWAN_COUNTRIES = [
|
|
65
66
|
'台北市',
|