@mptw/skylens-ui 1.4.58 → 1.4.60

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.
@@ -4,32 +4,33 @@
4
4
  ref="button"
5
5
  )
6
6
  a(
7
- href="javascript:;"
8
- @click="onClickedToggle"
9
- ref="toggle"
10
- ).toggle-button
11
- .date-range
12
- SLIcon(icon="calendar")
13
- span.divider
14
- span.date-range {{ dateRange1 }}
15
- span.range-days(v-if='dateRange1Days') {{ dateRange1Days }} 天
16
- .compare-date-range(v-if="dateRange2 && showCompareSwitch")
17
- span v.s.
18
- span {{ dateRange2 }}
7
+ href="javascript:;"
8
+ @click="onClickedToggle"
9
+ ref="toggle"
10
+ ).toggle-button
11
+ .date-range
12
+ SLIcon(icon="calendar")
13
+ span.divider
14
+ span.date-range {{ dateRange1 }}
15
+ span.range-days(v-if='dateRange1Days') {{ dateRange1Days }} 天
16
+ .compare-date-range(v-if="dateRange2 && showCompareSwitch")
17
+ span v.s.
18
+ span {{ dateRange2 }}
19
19
  ClientOnly
20
20
  Teleport(to="body")
21
21
  SLCalendarPopup(
22
- :data-source-type='dataSourceType'
23
- :show-quicks="showQuicks"
24
- :showCompareSwitch="showCompareSwitch"
25
- :min-date="minDate"
26
- :maxDate="maxDate"
27
- :maxDays="maxDays"
28
- :modelValue="modelValue"
29
- @compare:change="onCompareChanged"
30
- @update:modelValue="onInputed"
31
- ref="popup"
32
- )
22
+ :data-source-type='dataSourceType'
23
+ :show-quicks="showQuicks"
24
+ :allow-quicks='allowQuicks'
25
+ :showCompareSwitch="showCompareSwitch"
26
+ :min-date="minDate"
27
+ :maxDate="maxDate"
28
+ :maxDays="maxDays"
29
+ :modelValue="modelValue"
30
+ @compare:change="onCompareChanged"
31
+ @update:modelValue="onInputed"
32
+ ref="popup"
33
+ )
33
34
  </template>
34
35
 
35
36
  <script lang="ts">
@@ -57,6 +58,15 @@ export default defineComponent({
57
58
  type: Boolean,
58
59
  default: true,
59
60
  },
61
+ allowQuicks: {
62
+ type: Array as PropType<Array<string>>,
63
+ default: () => [
64
+ 'last7Days',
65
+ 'last30Days',
66
+ 'last90Days',
67
+ 'lastMonth'
68
+ ],
69
+ },
60
70
  showCompareSwitch: {
61
71
  type: Boolean,
62
72
  default: true,
@@ -141,6 +141,15 @@ export default defineComponent({
141
141
  type: Boolean,
142
142
  default: true,
143
143
  },
144
+ allowQuicks: {
145
+ type: Array as PropType<Array<string>>,
146
+ default: () => [
147
+ 'last7Days',
148
+ 'last30Days',
149
+ 'last90Days',
150
+ 'lastMonth'
151
+ ],
152
+ },
144
153
  showCompareSwitch: {
145
154
  type: Boolean,
146
155
  default: true,
@@ -168,7 +177,7 @@ export default defineComponent({
168
177
  setup(props, { emit }) {
169
178
  const runtimeConfig = useRuntimeConfig();
170
179
 
171
- const { dataSourceType, minDate, maxDate, maxDays, modelValue } =
180
+ const { allowQuicks, dataSourceType, minDate, maxDate, maxDays, modelValue } =
172
181
  toRefs(props);
173
182
 
174
183
  const el = shallowRef<HTMLElement | null>(null);
@@ -328,14 +337,25 @@ export default defineComponent({
328
337
  return formatDate(baseDate.value, "yyyy/MM/dd");
329
338
  });
330
339
  const quicks = computed(() => {
331
- const quicks = [
332
- { key: "last7Days", label: "過去7天" },
333
- { key: "last30Days", label: "過去30天" },
334
- ];
335
-
336
- if (maxDaysProxy.value >= 90) {
337
- quicks.push({ key: "last90Days", label: "過去90天" });
338
- }
340
+ const quicks: {
341
+ key: 'last7Days' | 'last30Days' | 'last90Days' | 'lastMonth';
342
+ label: string;
343
+ }[] = [];
344
+
345
+ allowQuicks.value.forEach((allowQuick) => {
346
+ if (allowQuick === 'last7Days') {
347
+ quicks.push({ key: "last7Days", label: "過去7天" });
348
+ }
349
+ if (allowQuick === 'last30Days') {
350
+ quicks.push({ key: "last30Days", label: "過去30天" });
351
+ }
352
+ if (allowQuick === 'last90Days' && maxDaysProxy.value >= 90) {
353
+ quicks.push({ key: "last90Days", label: "過去90天" });
354
+ }
355
+ if (allowQuick === 'lastMonth') {
356
+ quicks.push({ key: "lastMonth", label: "上個月" });
357
+ }
358
+ });
339
359
 
340
360
  // if (diffNow.value <= 0) {
341
361
  // quicks.push({ key: 'yesterday', label: '昨天' });
@@ -343,7 +363,7 @@ export default defineComponent({
343
363
  // quicks.push({ key: 'yesterday', label: '過去1天' });
344
364
  // }
345
365
 
346
- return [...quicks, { key: "lastMonth", label: "上個月" }];
366
+ return quicks;
347
367
  });
348
368
  const maxDate1 = computed(() => {
349
369
  return maxDate.value;
@@ -381,8 +401,8 @@ export default defineComponent({
381
401
  if (!dateRange1.value) return "";
382
402
 
383
403
  return `${dateRange1.value.start
384
- ? formatDate(dateRange1.value.start, "yyyy/MM/dd")
385
- : ""
404
+ ? formatDate(dateRange1.value.start, "yyyy/MM/dd")
405
+ : ""
386
406
  }${dateRange1.value.end
387
407
  ? `-${formatDate(dateRange1.value.end, "yyyy/MM/dd")}`
388
408
  : ""
@@ -425,8 +445,8 @@ export default defineComponent({
425
445
  if (!dateRange2.value) return "";
426
446
 
427
447
  return `${dateRange2.value.start
428
- ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
429
- : ""
448
+ ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
449
+ : ""
430
450
  }${dateRange2.value.end
431
451
  ? `-${formatDate(dateRange2.value.end, "yyyy/MM/dd")}`
432
452
  : ""
@@ -435,8 +455,8 @@ export default defineComponent({
435
455
  const dateRange2Style2 = computed(() => {
436
456
  if (!dateRange2.value) return "";
437
457
  return `${dateRange2.value.start
438
- ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
439
- : ""
458
+ ? formatDate(dateRange2.value.start, "yyyy/MM/dd")
459
+ : ""
440
460
  }${dateRange2.value.end
441
461
  ? ` - ${formatDate(dateRange2.value.end, "yyyy/MM/dd")}`
442
462
  : ""
@@ -40,7 +40,6 @@ import {
40
40
  ga4ev,
41
41
  } from "~ui/utils";
42
42
  import type IDateRange from "~ui/interface/IDateRange";
43
- import watermarkImg from "images/commons/watermark.svg";
44
43
 
45
44
  // http://www.excelcodex.com/2012/06/worksheets-naming-conventions/
46
45
  function safeSheetName(name: string) {
@@ -110,7 +109,7 @@ export default defineComponent({
110
109
  },
111
110
  customStyle: {
112
111
  type: Object as PropType<Partial<CSSStyleDeclaration>>,
113
- default: () => {},
112
+ default: () => { },
114
113
  },
115
114
  evCategory: {
116
115
  type: String,
@@ -138,6 +137,7 @@ export default defineComponent({
138
137
  let clickSubscriber: Subscription | null = null;
139
138
  let popperInstance: PopperInstance | null = null;
140
139
 
140
+ const watermarkImg = computed(() => '/assets/images/commons/watermark.svg')
141
141
  const styleOption = computed(() => {
142
142
  return Object.assign({}, DEFAULT_STYLE, customStyle.value);
143
143
  });
@@ -280,7 +280,7 @@ export default defineComponent({
280
280
  if (padding.value) dataURL = await addPadding(dataURL, padding.value);
281
281
  if (dateRanges.value?.length > 0)
282
282
  dataURL = await addDateRanges(dataURL, [...dateRanges.value].reverse());
283
- if (watermark.value) dataURL = await addWatermark(dataURL, watermarkImg);
283
+ if (watermark.value) dataURL = await addWatermark(dataURL, watermarkImg.value);
284
284
  downloadURL(dataURL, `${fileName.value}.png`);
285
285
  }
286
286
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mptw/skylens-ui",
3
3
  "type": "module",
4
- "version": "1.4.58",
4
+ "version": "1.4.60",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",