@94ai/nf-search-form 3.1.36 → 3.1.38
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/lib/index.d.ts +28 -26
- package/lib/nf-column-check-dialog.vue.d.ts +1 -1
- package/lib/nf-search-form-item.vue.d.ts +1 -10
- package/lib/nf-search-form.cjs.js +626 -11676
- package/lib/nf-search-form.esm-bundler.js +626 -11676
- package/lib/nf-search-form.vue.d.ts +10 -9
- package/lib/types.d.ts +2 -2
- package/package/README.md +137 -0
- package/package/index.ts +8 -0
- package/package/nf-column-check-dialog.vue +161 -0
- package/package/nf-number-range.vue +130 -0
- package/package/nf-search-form-item.vue +380 -0
- package/package/nf-search-form.vue +737 -0
- package/package/nf-time-range.vue +128 -0
- package/package/style/css.ts +1 -0
- package/package/style/index.ts +1 -0
- package/package/tools.ts +163 -0
- package/package/types.ts +85 -0
- package/package.json +15 -15
- package/lib/nf-search-form.css +0 -824
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="nf-time-range">
|
|
3
|
+
<el-time-select
|
|
4
|
+
v-model="startTime"
|
|
5
|
+
v-bind="inputAttrStart"
|
|
6
|
+
:placeholder="startPlaceholder"
|
|
7
|
+
class="nf-time-range-el-time-select"
|
|
8
|
+
v-on="inputlistens"
|
|
9
|
+
/>
|
|
10
|
+
<span class="symbol">~</span>
|
|
11
|
+
<el-time-select
|
|
12
|
+
v-model="endTime"
|
|
13
|
+
v-bind="inputAttrEnd"
|
|
14
|
+
:placeholder="endPlaceholder"
|
|
15
|
+
class="nf-time-range-el-time-select"
|
|
16
|
+
v-on="inputlistens"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { defineComponent } from 'vue-demi'
|
|
24
|
+
|
|
25
|
+
export default defineComponent({
|
|
26
|
+
name: "NfTimeRange",
|
|
27
|
+
})
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
<script lang="ts" setup>
|
|
32
|
+
import {
|
|
33
|
+
computed,
|
|
34
|
+
getCurrentInstance,
|
|
35
|
+
ref,
|
|
36
|
+
watch
|
|
37
|
+
} from 'vue-demi'
|
|
38
|
+
|
|
39
|
+
const props = withDefaults(defineProps<{
|
|
40
|
+
value?: string[],
|
|
41
|
+
endPlaceholder: string
|
|
42
|
+
startPlaceholder: string
|
|
43
|
+
}>(), {
|
|
44
|
+
value: () => [],
|
|
45
|
+
endPlaceholder: '结束时间',
|
|
46
|
+
startPlaceholder: '开始时间'
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const emit = defineEmits<{
|
|
50
|
+
(e: 'input', event: [string | undefined, string | undefined]): void
|
|
51
|
+
(e: 'change', event: [string | undefined, string | undefined]): void
|
|
52
|
+
}>()
|
|
53
|
+
|
|
54
|
+
const startTime = ref<string>()
|
|
55
|
+
const endTime = ref<string>()
|
|
56
|
+
|
|
57
|
+
const instace = getCurrentInstance()?.proxy
|
|
58
|
+
|
|
59
|
+
const inputlistens = computed(() => {
|
|
60
|
+
const list = Object.assign({},
|
|
61
|
+
instace?.$listeners,
|
|
62
|
+
{
|
|
63
|
+
change: function() {
|
|
64
|
+
emit('change', [startTime.value, endTime.value])
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
delete list.input
|
|
69
|
+
return list
|
|
70
|
+
})
|
|
71
|
+
const inputAttrStart = computed(() => {
|
|
72
|
+
const attrs = instace?.$attrs
|
|
73
|
+
delete attrs?.type
|
|
74
|
+
const pickerOptions = attrs?.['picker-options'] || {}
|
|
75
|
+
return {
|
|
76
|
+
...(attrs || {}),
|
|
77
|
+
'picker-options': {
|
|
78
|
+
...pickerOptions
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
const inputAttrEnd = computed(() =>{
|
|
83
|
+
const attrs = instace?.$attrs
|
|
84
|
+
delete attrs?.type
|
|
85
|
+
const pickerOptions = attrs?.['picker-options'] || {}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
...attrs,
|
|
89
|
+
'picker-options': {
|
|
90
|
+
...pickerOptions,
|
|
91
|
+
minTime: startTime.value
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
watch(() => {
|
|
98
|
+
return props.value
|
|
99
|
+
}, () => {
|
|
100
|
+
startTime.value = props.value?.[0]
|
|
101
|
+
endTime.value = props.value?.[1]
|
|
102
|
+
}, {
|
|
103
|
+
deep: true,
|
|
104
|
+
immediate: true
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
watch(() => {
|
|
108
|
+
return startTime.value
|
|
109
|
+
}, () => {
|
|
110
|
+
if (startTime.value && endTime.value) {
|
|
111
|
+
const [h1, m1] = String(startTime.value).split(":");
|
|
112
|
+
const [h2, m2] = String(endTime.value).split(":");
|
|
113
|
+
const t1 = new Date();
|
|
114
|
+
t1.setHours(Number(h1), Number(m1));
|
|
115
|
+
const t2 = new Date();
|
|
116
|
+
t2.setHours(Number(h2), Number(m2));
|
|
117
|
+
if (t1.getTime() > t2.getTime()) {
|
|
118
|
+
endTime.value = undefined
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
emit('input', [startTime.value, endTime.value])
|
|
122
|
+
})
|
|
123
|
+
watch(() => {
|
|
124
|
+
return endTime.value
|
|
125
|
+
}, () => {
|
|
126
|
+
emit('input', [startTime.value, endTime.value])
|
|
127
|
+
})
|
|
128
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/css/nf-search-form.css'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/nf-search-form.scss'
|
package/package/tools.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建唯一的字符串
|
|
3
|
+
* @return {string} ojgdvbvaua40
|
|
4
|
+
*/
|
|
5
|
+
export function createUniqueString() {
|
|
6
|
+
const timestamp = +new Date() + ''
|
|
7
|
+
const randomNum = parseInt(String((1 + Math.random()) * 65536)) + ''
|
|
8
|
+
return (+(randomNum + timestamp)).toString(32)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function debounce(func, wait, immediate) {
|
|
12
|
+
let timeout, args, context, timestamp, result
|
|
13
|
+
|
|
14
|
+
const later = function() {
|
|
15
|
+
// 据上一次触发时间间隔
|
|
16
|
+
const last = +new Date() - timestamp
|
|
17
|
+
|
|
18
|
+
// 上次被包装函数被调用时间间隔last小于设定时间间隔wait
|
|
19
|
+
if (last < wait && last > 0) {
|
|
20
|
+
timeout = setTimeout(later, wait - last)
|
|
21
|
+
} else {
|
|
22
|
+
timeout = null
|
|
23
|
+
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
|
24
|
+
if (!immediate) {
|
|
25
|
+
result = func.apply(context, args)
|
|
26
|
+
if (!timeout) context = args = null
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return function(...args) {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
context = this
|
|
34
|
+
timestamp = +new Date()
|
|
35
|
+
const callNow = immediate && !timeout
|
|
36
|
+
// 如果延时不存在,重新设定延时
|
|
37
|
+
if (!timeout) timeout = setTimeout(later, wait)
|
|
38
|
+
if (callNow) {
|
|
39
|
+
result = func.apply(context, args)
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
context = args = null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export const on = (function() {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
if (document.addEventListener) {
|
|
50
|
+
return function(event, handler, element = window) {
|
|
51
|
+
if (element && event && handler) {
|
|
52
|
+
element.addEventListener(event, handler, false)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
return function(event, handler, element = window) {
|
|
57
|
+
if (element && event && handler) {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
element.attachEvent('on' + event, handler)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})()
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 移除事件监听
|
|
67
|
+
*/
|
|
68
|
+
export const off = (function() {
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
if (document.removeEventListener) {
|
|
71
|
+
return function(event, handler, element = window) {
|
|
72
|
+
if (element && event) {
|
|
73
|
+
element.removeEventListener(event, handler, false)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
return function(event, handler, element = window) {
|
|
78
|
+
if (element && event) {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
element.detachEvent('on' + event, handler)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* elementui日期时间范围 快捷选项
|
|
89
|
+
*/
|
|
90
|
+
export const pickerOptionsRange = {
|
|
91
|
+
shortcuts: [
|
|
92
|
+
{
|
|
93
|
+
text: '今天',
|
|
94
|
+
onClick(picker) {
|
|
95
|
+
const end = new Date()
|
|
96
|
+
const start = new Date(new Date().toDateString())
|
|
97
|
+
start.setTime(start.getTime())
|
|
98
|
+
picker.$emit('pick', [start, end])
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
text: '最近一周',
|
|
103
|
+
onClick(picker) {
|
|
104
|
+
const end = new Date()
|
|
105
|
+
const start = new Date()
|
|
106
|
+
start.setTime(end.getTime() - 3600 * 1000 * 24 * 7)
|
|
107
|
+
picker.$emit('pick', [start, end])
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
text: '最近一个月',
|
|
112
|
+
onClick(picker) {
|
|
113
|
+
const end = new Date()
|
|
114
|
+
const start = new Date()
|
|
115
|
+
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
|
|
116
|
+
picker.$emit('pick', [start, end])
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
text: '最近三个月',
|
|
121
|
+
onClick(picker) {
|
|
122
|
+
const end = new Date()
|
|
123
|
+
const start = new Date()
|
|
124
|
+
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
|
|
125
|
+
picker.$emit('pick', [start, end])
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* elementui月份范围 快捷选项
|
|
133
|
+
*/
|
|
134
|
+
export const pickerOptionsRangeMonth = {
|
|
135
|
+
shortcuts: [
|
|
136
|
+
{
|
|
137
|
+
text: '今年至今',
|
|
138
|
+
onClick(picker) {
|
|
139
|
+
const end = new Date()
|
|
140
|
+
const start = new Date(new Date().getFullYear(), 0)
|
|
141
|
+
picker.$emit('pick', [start, end])
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
text: '最近半年',
|
|
146
|
+
onClick(picker) {
|
|
147
|
+
const end = new Date()
|
|
148
|
+
const start = new Date()
|
|
149
|
+
start.setMonth(start.getMonth() - 6)
|
|
150
|
+
picker.$emit('pick', [start, end])
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
text: '最近一年',
|
|
155
|
+
onClick(picker) {
|
|
156
|
+
const end = new Date()
|
|
157
|
+
const start = new Date()
|
|
158
|
+
start.setMonth(start.getMonth() - 12)
|
|
159
|
+
picker.$emit('pick', [start, end])
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
package/package/types.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export type NfSearchFormItemOption = {
|
|
2
|
+
/**
|
|
3
|
+
* nf-form-item配置
|
|
4
|
+
*/
|
|
5
|
+
label?: string,
|
|
6
|
+
addLabel?: string,
|
|
7
|
+
prop?: string,
|
|
8
|
+
width?: string,
|
|
9
|
+
isShowColon?: boolean,
|
|
10
|
+
hidden?: boolean,
|
|
11
|
+
required?: boolean,
|
|
12
|
+
rules?: Record<string, any>,
|
|
13
|
+
size?: 'medium' | 'small' | 'mini'
|
|
14
|
+
labelWidth?: string
|
|
15
|
+
'is-range'?: boolean,
|
|
16
|
+
showMessage?: boolean,
|
|
17
|
+
inlineMessage?: boolean,
|
|
18
|
+
/**
|
|
19
|
+
* 设置SearchItem显示所属分类
|
|
20
|
+
*/
|
|
21
|
+
category?: string,
|
|
22
|
+
/**
|
|
23
|
+
* 设置SearchFormModel初始值
|
|
24
|
+
*/
|
|
25
|
+
initValue?: any,
|
|
26
|
+
/**
|
|
27
|
+
* 定制化SearchItem插槽
|
|
28
|
+
*/
|
|
29
|
+
slot?: string,
|
|
30
|
+
/**
|
|
31
|
+
* 定制化SearchItem类名
|
|
32
|
+
*/
|
|
33
|
+
class?: string,
|
|
34
|
+
/**
|
|
35
|
+
* 定制化SearchItem?提示
|
|
36
|
+
*/
|
|
37
|
+
tooltip?: {
|
|
38
|
+
slot: string,
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* 时间类范围类型
|
|
42
|
+
*/
|
|
43
|
+
type?: 'monthrange' | 'datetimerange' |
|
|
44
|
+
'daterange' | 'yearrange' |
|
|
45
|
+
'halfyearrange' | 'quarterrange' |
|
|
46
|
+
'date' | 'month' | 'week' | 'dates',
|
|
47
|
+
/**
|
|
48
|
+
* 所有支持的element类型
|
|
49
|
+
*/
|
|
50
|
+
element?: 'el-input' | 'el-select' | 'custom-select' | 'ai-select' | 'ai-custom-select' |
|
|
51
|
+
'el-input-number' | 'el-date-picker' |
|
|
52
|
+
'el-cascader' | 'el-time-select' |
|
|
53
|
+
'el-time-picker' | 'number-range' |
|
|
54
|
+
'nf-date-picker' |
|
|
55
|
+
'nf-quarter-picker' | 'nf-half-year-picker' |
|
|
56
|
+
'nf-double-year' | 'nf-double-week' |
|
|
57
|
+
'nf-double-half-year' | 'nf-double-quarter' | 'nf-select-transfer',
|
|
58
|
+
/**
|
|
59
|
+
* 支持所有element类型的element组件的配置时间
|
|
60
|
+
*/
|
|
61
|
+
events?: Record<string, Function>,
|
|
62
|
+
/**
|
|
63
|
+
* 支持所有element类型的element组件的配置属性,如以下
|
|
64
|
+
*/
|
|
65
|
+
placeholder?: string,
|
|
66
|
+
virtualList?: boolean,
|
|
67
|
+
'controls-position'?: 'right' | 'left',
|
|
68
|
+
clearable?: boolean
|
|
69
|
+
startPlaceholder?: string
|
|
70
|
+
rangeSeparator?: string
|
|
71
|
+
endPlaceholder?: string
|
|
72
|
+
defaultTime?: string[]
|
|
73
|
+
options?: {
|
|
74
|
+
label: string,
|
|
75
|
+
value: string | number
|
|
76
|
+
}[],
|
|
77
|
+
'picker-options'?: {
|
|
78
|
+
start: string,
|
|
79
|
+
step: string,
|
|
80
|
+
end: string
|
|
81
|
+
},
|
|
82
|
+
valueFormat?: string
|
|
83
|
+
min?: 0,
|
|
84
|
+
// ...
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-search-form",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.38",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "zoujiahe <zoujiahe@94ai.com>",
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@94ai/nf-action": "^3.1.
|
|
18
|
-
"@94ai/nf-double-half-year": "^3.1.
|
|
19
|
-
"@94ai/nf-double-quarter": "^3.1.
|
|
20
|
-
"@94ai/nf-double-week": "^3.1.
|
|
21
|
-
"@94ai/nf-double-year": "^3.1.
|
|
22
|
-
"@94ai/nf-form": "^3.1.
|
|
23
|
-
"@94ai/nf-form-item": "^3.1.
|
|
24
|
-
"@94ai/nf-half-year-picker": "^3.1.
|
|
25
|
-
"@94ai/nf-quarter-picker": "^3.1.
|
|
26
|
-
"@94ai/nf-select-transfer": "^3.1.
|
|
27
|
-
"@94ai/nf-theme-chalk": "^3.1.
|
|
28
|
-
"@94ai/nf-virtual-select": "^3.1.
|
|
29
|
-
"@94ai/nf-year-picker": "^3.1.
|
|
17
|
+
"@94ai/nf-action": "^3.1.38",
|
|
18
|
+
"@94ai/nf-double-half-year": "^3.1.38",
|
|
19
|
+
"@94ai/nf-double-quarter": "^3.1.38",
|
|
20
|
+
"@94ai/nf-double-week": "^3.1.38",
|
|
21
|
+
"@94ai/nf-double-year": "^3.1.38",
|
|
22
|
+
"@94ai/nf-form": "^3.1.38",
|
|
23
|
+
"@94ai/nf-form-item": "^3.1.38",
|
|
24
|
+
"@94ai/nf-half-year-picker": "^3.1.38",
|
|
25
|
+
"@94ai/nf-quarter-picker": "^3.1.38",
|
|
26
|
+
"@94ai/nf-select-transfer": "^3.1.38",
|
|
27
|
+
"@94ai/nf-theme-chalk": "^3.1.38",
|
|
28
|
+
"@94ai/nf-virtual-select": "^3.1.38",
|
|
29
|
+
"@94ai/nf-year-picker": "^3.1.28",
|
|
30
30
|
"vue-demi": "^0.14.5"
|
|
31
31
|
},
|
|
32
32
|
"peerDependenciesMeta": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"types": "lib/index.d.ts",
|
|
43
43
|
"main": "lib/nf-search-form.cjs.js",
|
|
44
44
|
"module": "lib/nf-search-form.esm-bundler.js",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2b60696b405feafbbaeed385e5bcf666ceefbf2c"
|
|
46
46
|
}
|