@netang/quasar 0.1.43 → 0.1.45
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/components/private/table-visible-columns-button/index.vue +5 -0
- package/package.json +1 -1
- package/utils/$table.js +14 -6
- package/utils/getTime.js +113 -106
- package/utils/useSearch.js +10 -7
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
v-for="item in tableColumns"
|
|
37
37
|
clickable
|
|
38
38
|
@click="onTableVisible(item)"
|
|
39
|
+
v-if="tableShowVisibleColumns"
|
|
39
40
|
>
|
|
40
41
|
<q-item-section>{{item.label}}</q-item-section>
|
|
41
42
|
<q-item-section side>
|
|
@@ -71,6 +72,8 @@ export default {
|
|
|
71
72
|
const {
|
|
72
73
|
// 表格列数据(对象数组)
|
|
73
74
|
tableColumns,
|
|
75
|
+
// 表格是否显示可见列
|
|
76
|
+
tableShowVisibleColumns,
|
|
74
77
|
// 表格可见列
|
|
75
78
|
tableVisibleColumns,
|
|
76
79
|
// 表格宫格
|
|
@@ -94,6 +97,8 @@ export default {
|
|
|
94
97
|
return {
|
|
95
98
|
// 表格列数据(对象数组)
|
|
96
99
|
tableColumns,
|
|
100
|
+
// 表格是否显示可见列
|
|
101
|
+
tableShowVisibleColumns,
|
|
97
102
|
// 表格可见列
|
|
98
103
|
tableVisibleColumns,
|
|
99
104
|
// 表格宫格
|
package/package.json
CHANGED
package/utils/$table.js
CHANGED
|
@@ -26,6 +26,7 @@ import $n_isValidObject from '@netang/utils/isValidObject'
|
|
|
26
26
|
import $n_isValidValue from '@netang/utils/isValidValue'
|
|
27
27
|
import $n_slash from '@netang/utils/slash'
|
|
28
28
|
import $n_http from '@netang/utils/http'
|
|
29
|
+
import $n_cb from '@netang/utils/cb'
|
|
29
30
|
|
|
30
31
|
import $n_$power from './$power'
|
|
31
32
|
import $n_dict from './dict'
|
|
@@ -146,8 +147,8 @@ function create(options) {
|
|
|
146
147
|
let tableColumns
|
|
147
148
|
let tableImgNames
|
|
148
149
|
|
|
149
|
-
//
|
|
150
|
-
let
|
|
150
|
+
// 是否显示可见列
|
|
151
|
+
let tableShowVisibleColumns
|
|
151
152
|
// 表格可见列
|
|
152
153
|
let tableVisibleColumns
|
|
153
154
|
// 表格加载状态
|
|
@@ -337,11 +338,10 @@ function create(options) {
|
|
|
337
338
|
}
|
|
338
339
|
})
|
|
339
340
|
|
|
340
|
-
// 获取可见列缓存
|
|
341
|
-
visibleColumnsCache = o.showVisibleColumns && isCache ? $n_storage.get('table:visible_columns:' + cacheName) : []
|
|
342
|
-
|
|
343
341
|
// 表格可见列
|
|
344
|
-
const _tableVisibleColumns =
|
|
342
|
+
const _tableVisibleColumns = o.showVisibleColumns && isCache ?
|
|
343
|
+
$n_cb($n_storage.get('table:visible_columns:' + cacheName), e => $n_isValidArray(e) ? e : [])
|
|
344
|
+
: $n_uniq([...o.visibleColumns])
|
|
345
345
|
|
|
346
346
|
// 表格翻页参数
|
|
347
347
|
const _tablePagination = $route.fullPath ? o.pagination : {}
|
|
@@ -368,6 +368,9 @@ function create(options) {
|
|
|
368
368
|
// 表格列
|
|
369
369
|
tableColumns.value = _tableColumns
|
|
370
370
|
|
|
371
|
+
// 表格是否显示可见列
|
|
372
|
+
tableShowVisibleColumns.value = o.showVisibleColumns
|
|
373
|
+
|
|
371
374
|
// 表格可见列
|
|
372
375
|
tableVisibleColumns.value = _tableVisibleColumns
|
|
373
376
|
|
|
@@ -403,6 +406,9 @@ function create(options) {
|
|
|
403
406
|
// 表格列
|
|
404
407
|
tableColumns = ref(_tableColumns)
|
|
405
408
|
|
|
409
|
+
// 表格是否显示可见列
|
|
410
|
+
tableShowVisibleColumns = ref(o.showVisibleColumns)
|
|
411
|
+
|
|
406
412
|
// 表格可见列
|
|
407
413
|
tableVisibleColumns = ref(_tableVisibleColumns)
|
|
408
414
|
|
|
@@ -1081,6 +1087,8 @@ function create(options) {
|
|
|
1081
1087
|
tableSeparator,
|
|
1082
1088
|
// 表格列数据(对象数组)
|
|
1083
1089
|
tableColumns,
|
|
1090
|
+
// 表格是否显示可见列
|
|
1091
|
+
tableShowVisibleColumns,
|
|
1084
1092
|
// 表格可见列
|
|
1085
1093
|
tableVisibleColumns,
|
|
1086
1094
|
// 表格行数据
|
package/utils/getTime.js
CHANGED
|
@@ -1,106 +1,113 @@
|
|
|
1
|
-
import $
|
|
2
|
-
|
|
3
|
-
import $
|
|
4
|
-
|
|
5
|
-
import $
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
import $n_get from 'lodash/get'
|
|
2
|
+
|
|
3
|
+
import $n_isValidString from '@netang/utils/isValidString'
|
|
4
|
+
import $n_toDate from '@netang/utils/toDate'
|
|
5
|
+
import $n_indexOf from '@netang/utils/indexOf'
|
|
6
|
+
|
|
7
|
+
import $n_timestamp from './timestamp'
|
|
8
|
+
|
|
9
|
+
import { date as quasarDate } from 'quasar'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 获取时间
|
|
13
|
+
*/
|
|
14
|
+
export default function getTime(time, options, defaultValue = '') {
|
|
15
|
+
|
|
16
|
+
if (! time) {
|
|
17
|
+
return $n_isValidString(options) ? options : defaultValue
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 分隔符
|
|
21
|
+
const separator = $n_get(options, 'separator', '-')
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
hideCurrentYear,
|
|
25
|
+
showSecond,
|
|
26
|
+
format,
|
|
27
|
+
calendar,
|
|
28
|
+
showCalendarToday,
|
|
29
|
+
showCalendarTime,
|
|
30
|
+
|
|
31
|
+
} = Object.assign({
|
|
32
|
+
// 默认格式化
|
|
33
|
+
format: `MM${separator}DD HH:mm`,
|
|
34
|
+
// 是否显示秒
|
|
35
|
+
showSecond: false,
|
|
36
|
+
// 是否隐藏当前年份
|
|
37
|
+
hideCurrentYear: false,
|
|
38
|
+
// 是否显示日历格式
|
|
39
|
+
calendar: false,
|
|
40
|
+
// 是否显示日历今天
|
|
41
|
+
showCalendarToday: false,
|
|
42
|
+
// 是否显示日历时间
|
|
43
|
+
showCalendarTime: false,
|
|
44
|
+
}, options)
|
|
45
|
+
|
|
46
|
+
// 传入时间
|
|
47
|
+
const date = $n_toDate(time)
|
|
48
|
+
|
|
49
|
+
// 当前时间
|
|
50
|
+
const now = $n_toDate($n_timestamp())
|
|
51
|
+
|
|
52
|
+
// 如果是自然化时间
|
|
53
|
+
// 如果是今天, 则显示时分秒
|
|
54
|
+
// 如果是昨天, 则显示昨天
|
|
55
|
+
// 如果是本周, 则显示星期几
|
|
56
|
+
// 如果是本年, 则显示某月某日
|
|
57
|
+
// 如果是非本年, 则显示某年某月某日
|
|
58
|
+
if (calendar) {
|
|
59
|
+
|
|
60
|
+
// 当前时间
|
|
61
|
+
let time = ''
|
|
62
|
+
|
|
63
|
+
// 如果是今年
|
|
64
|
+
if (quasarDate.formatDate(date, 'YYYY') === quasarDate.formatDate(now, 'YYYY')) {
|
|
65
|
+
|
|
66
|
+
const formatYmd = `YYYY${separator}MM${separator}DD`
|
|
67
|
+
|
|
68
|
+
// 如果是今天
|
|
69
|
+
const resDay = quasarDate.formatDate(date, formatYmd)
|
|
70
|
+
if (resDay === quasarDate.formatDate(now, formatYmd)) {
|
|
71
|
+
return showCalendarToday ? '今天' : quasarDate.formatDate(date, 'HH:mm' + (showSecond ? ':ss' : ''))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 判断是否是昨天
|
|
75
|
+
if (resDay === quasarDate.formatDate(quasarDate.subtractFromDate(now, { days: 1 }), formatYmd)) {
|
|
76
|
+
time = '昨天'
|
|
77
|
+
|
|
78
|
+
// 是否为本周(判断日期在本年是第几周 如果相同, 则是本周)
|
|
79
|
+
} else if (quasarDate.formatDate(date, 'YYYY w') === quasarDate.formatDate(now, 'YYYY w')) {
|
|
80
|
+
time = quasarDate.formatDate(date, 'dddd')
|
|
81
|
+
|
|
82
|
+
// 否则显示某月某日
|
|
83
|
+
} else {
|
|
84
|
+
time = quasarDate.formatDate(date, 'MM月DD日')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 否则显示某年某月某日
|
|
88
|
+
} else {
|
|
89
|
+
time = quasarDate.formatDate(date, 'YYYY年MM月DD日')
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 是否显示日历时间
|
|
93
|
+
if (showCalendarTime) {
|
|
94
|
+
return time + ' ' + quasarDate.formatDate(date, 'HH:mm' + (showSecond ? ':ss' : ''))
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 否则仅显示日期
|
|
98
|
+
return time
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 如果是今年是否显示
|
|
102
|
+
if (
|
|
103
|
+
$n_indexOf(format, 'YYYY') === -1
|
|
104
|
+
&& (
|
|
105
|
+
! hideCurrentYear
|
|
106
|
+
|| quasarDate.formatDate(date, 'YYYY') !== quasarDate.formatDate(now, 'YYYY')
|
|
107
|
+
)
|
|
108
|
+
) {
|
|
109
|
+
format = 'YYYY' + separator + format
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return quasarDate.formatDate(date, format + (showSecond ? ':ss' : ''))
|
|
113
|
+
}
|
package/utils/useSearch.js
CHANGED
|
@@ -114,13 +114,16 @@ function setItemCompare(item) {
|
|
|
114
114
|
// 值2 比较类型条件
|
|
115
115
|
item.compareOptions2 = []
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
item.compareOptions2.push(
|
|
117
|
+
if (
|
|
118
|
+
// 如果比较类型有 >
|
|
119
|
+
$n_findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GT }) > -1
|
|
120
|
+
// 如果比较类型有 >=
|
|
121
|
+
|| $n_findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GTE }) > -1
|
|
122
|
+
) {
|
|
123
|
+
item.compareOptions2.push(
|
|
124
|
+
{ label: '<', value: dicts.SEARCH_COMPARE_TYPE__LT },
|
|
125
|
+
{ label: '≤', value: dicts.SEARCH_COMPARE_TYPE__LTE },
|
|
126
|
+
)
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
|